LCD 16×2 using I2C in LPC2148
In this tutorial, I am going to show you How to connect LCD using I2C with an ARM7 mcrocontroller. I am using LPC2148 but the process is same for other ARM7 devices. PCF8574 acts as an I2C extender and is being used to connect LCD with the LPC2148.
First of all let’s see the connections between the PCF8574 and the LCD.
As shown in the figure, connect the first pin of the PCF8574 to the VSS of the LCD, 2nd pin to the VCC and so on. The input pins of the PCF8574 i.e. SCL and SDA should be connected with the SCL and SDA of the microcontroller. LPC2148 do not have internal pull-ups so we need to connect external pull-up resistors (around 4k) with the SCL and SDA pins. More connections are given below…
Data transmission via I2C require some steps to be followed. They are as follows:
Start -> Write Address -> Write data -> Stop to write data to the slave. I am going to cover only writing data to the slave and not reading from slave.
The following are the functions used during an I2C transmission:
The following are the functions used for writing data to the LCD:
Copy all these header files to a location and add the path to the C/C++ in the project setting as shown in the picture below
You can see the “hello!” is printed on the display in the proteus. For more working, see the video below
- Interface WS2812 with STM32 April 16, 2021
- PWM with DMA in STM32 April 8, 2021
- Control Stepper motor using Rotary Angle Sensor March 21, 2021
- External Interrupt using Registers March 17, 2021
- STM32F103 Clock Setup using Registers March 3, 2021
- STM32 I2C Configuration using Registers February 26, 2021