Arduino Projects

Arduino I2C-supported 16×2 LCD, Example with Circuit diagram and Programming

Arduino 16×2 LCD, Example:

Arduino course

In this example, I am going to explain how to print a text message on an Arduino I2C-supported 16×2 LCD. This is the most commonly used LCD and you are going to need this LCD in your upcoming projects for printing text messages and sensors values, and for creating menus etc.

Arduino course

Amazon Links:

Arduino Uno

Arduino Nano

SSD1306 Oled display

HC-SR04 Ultrasonic Sensor

5V Buzzer

I2C supported 16×2 LCD

Other Tools and Components:

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

Arduino I2C-supported 16×2 LCD Circuit Diagram

Anyway, this is the i2c version of the 16×2 LCD because it has this driver on its backside so you don’t need to connect a lot of wires. You only need to use 4 wires. All the 4 pins are properly labeled with GND, VCC, SDA, and SCL.

Arduino course

Simply connect the VCC and GND pins to the Arduino 5V and GND pins; and connect the SDA and SCL pins to the Arduino A4 and A5 pins. A4 is the SDA and A5 is the SCL. I have already explained this. It also has a blue color potentiometer to control the LCD contrast or brightness. Now let’s go ahead and take a look at the programming.

Arduino 16×2 LCD Programming:

Before, you start the programming, first of all, make sure you have installed the LiquidCrystal library. For this simply copy this name” LiquidCrystal_I2C”. Then go to the Sketch menu > then Include Library and click on the manage libraries. Paste the library name in the search box. You can see I have already installed this library and you also need to install the same library.

Arduino course


So, I started off by adding the LiquidCrystal_I2C.h header file.

This line initializes an instance of the LiquidCrystal_I2C class named lcd. The constructor takes three arguments:

0x27 is the I2C address of the LCD module. The specific address may vary depending on the configuration of your LCD module. You can find the I2C address by running an I2C scanner sketch which you can download from the article.

16 is the number of columns in the LCD and 2 is the number of rows in the LCD.

In the void setup() function,

The lcd.init() function initializes the LCD by sending the necessary commands over the I2C bus.

The lcd.clear() function clears the LCD screen, making sure it’s empty or blank.

The lcd.backlight() function turns ON the backlight; if the LCD module has it. If your LCD doesn’t have backlight support then this command will not affect the display.

The lcd.setCursor() function is used to select one of the two rows and 16 columns. The first number is used to select the column, in my case I have selected column 1, the index starts from 0 all the way to 15.

The 2nd number is used to select the row, 0 means first row and 1 means 2nd row. In my case I have selected the first row. Now, after selecting the column and row next we use the lcd.print command to write text on the LCD. Make sure you use double quotes for printing strings. If you want to display numbers and variable data on the LCD then there is no need to use the double quotes, just write the variable name or number and that’s it.

Arduino course

video tutorial


Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button