![]() |
VOOZH | about |
In this article, we will learn how to interface LCD displays with Arduino Uno R3.
Arduino is an open-source electronics platform. It consists ATmega328P 8-bit Microcontroller. It can be able to read inputs from different sensors & we can send instructions to the microcontroller in the Arduino. It provides Arduino IDE to write code & connect the hardware devices like Arduino boards & sensors.
LCD stands for Liquid Crystal Display. LCD is a flat-paneled display. It uses liquid crystals combined with polarized to display the content. LCD uses the light modulation property of LCD. LCD is available both in Monochrome and Multicolor. It cannot emit light directly without a backlight. In some LCDs, It displays the content only with the help of a backlight in a dark place.
I2C or IIC stands for Inter-Integrated Communication. I2C is a serial communication interface to communicate with other I2C devices. I2C uses multi-master / multi slave method. I2C uses 2 lines named SCL and SDA for transmission/reception and another 2 lines for power supply and ground. Each and every I2C device has I2C address to identify. I2C addresses of multiple devices may have the same address. The address is in the format of "0x20" (Example address). Steps to find out I2C address device is discussed in the following (step 4).
I2C LCD uses I2C communication interface to transfer the information required to display the content. I2C LCD requires only 2 lines (SDA and SCL) for transferring the data. So, the complexity of the circuit is reduced.
Interfacing I2C LCD to the Arduino:
I2C LCD can be connected to the Arduino directly with SDA pin to SDA pin and SCL pin to SCL pin as per the below circuit diagram. I2C LCD requires additional library to be installed. The next step is to connect the LCD to the address of the device using the following code. Those steps are explained in detail below.
Steps to interface LCD display with Arduino:
Step 1: Install the library for LCD display in Arduino IDE.
Step 2: Import "LiquidCrystal_I2C.h" header file in the code.
Step 3: Connect display device to Arduino.
Step 4: Find the I2C Address of the display device.
Online simulation of I2C address finding using Tinkercad: https://www.tinkercad.com/things/0siOxvpmVNJ
Arduino code for I2C Address finding:
Note: Make sure that you have connected the device properly.
Output:
Step 5: Define display device.
Step 6: Print characters in LCD.
Arduino code:
Working of code:
Initially, the library, address, height and width are defined in the code.
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x20, 16, 2);
In the setup() function, initialization and backlight are enabled.
lcd.init();
lcd.backlight();
In the loop() function,
lcd.clear();
// Set cursor (Column, Row)
lcd.setCursor(0, 0);
// print "Hello" at (0, 0)
lcd.print("Hello");
Output: