Skip to content

Interfacing 16x2 I2C LCD display with Arduino Uno

16x2 lcd

Table of Contents

Abstract

In this article, we will learn how to interface a 16×2 I2C LCD display with an Arduino Uno. Unlike the traditional parallel LCD interface, the I2C LCD uses only two communication wires, making the wiring simple, clean, and ideal for compact projects.

By the end of this tutorial, you will be able to display text on a 16×2 LCD using the Arduino Uno, understand the hardware connections, write the Arduino program, and verify the output using hardware or simulation.

🧭 Pre-Request

  • OS : Windows / Linux / Mac / Chrome
  • Arduino IDE

Hardware Required

🛠️
Get the right hardware kit
Arduino boards, sensors, and maker essential Kits—perfectly matched for your learning.
Explore Hardware →
  • Arduino Uno.
  • 16x2 I2C LCD display.
  • Resistors.
  • BreadBoard.
  • Mini USB Cable.
  • Connecting wires.
  • 5V DC power supply (Optional)
Components Purchase Link
Arduino Uno link
16x2 I2C LCD link
Mini USB Cable link
BreadBoard large : small
Connecting Wires link
5V DC Adaptor link

Don't own a hardware 😢

No worries,

💡Still you can learn using simulation. check out simulation part 😃.

💡Power your mission with reliable Arduino Kits. Explore Hardware →

Understanding I2C LCD Display

An I2C LCD uses an onboard PCF8574 I/O expander, which converts I2C signals into parallel data for the LCD controller. This drastically reduces the number of pins required.

Advantages of I2C LCD

  • Uses only 2 data lines (SDA & SCL)
  • Saves GPIO pins on Arduino
  • Clean wiring
  • Ideal for scalable projects

Connection Table

I2C LCD Pin Arduino Uno Pin
VCC 5V
GND GND
SDA A4
SCL A5

Note

💡 Most I2C LCD modules have a contrast adjustment potentiometer on the back.

Circuit Diagram

fig-Connection Diagram

📂 Code

Info

Before writing the main program, it is important to know the I2C address of your LCD module (commonly 0x27 or 0x3F).

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// I2C address (change if required)
LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {
  lcd.init();       // Initialize LCD
  lcd.backlight();  // Turn on backlight

  lcd.setCursor(0, 0);
  lcd.print("Welcome to");
  lcd.setCursor(0, 1);
  lcd.print("Aavishkarah");
  delay(3000);
}

void loop() {
  for(int i = 0; i < 10; i++) {
    lcd.clear();
    lcd.print(i);
    delay(1500);
  }
}

Code Explanation

Let’s break down the Arduino sketch line by line to clearly understand how the 16×2 I2C LCD works with the Arduino Uno.

👉 Imports

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
  • Wire.h Enables I2C communication between the microcontroller and external devices.
  • LiquidCrystal_I2C.h Provides easy-to-use functions to control a 16×2 LCD via I2C, such as printing text, clearing the screen, and moving the cursor.

💡 These libraries hide the low-level I2C complexity and make LCD control simple.

👉 Define LCD Pin Connections

LiquidCrystal_I2C lcd(0x27, 16, 2);
  • 0x27 → I2C address of the LCD module (Common addresses are 0x27 or 0x3F)
  • 16 → Number of columns
  • 2 → Number of rows

This line creates an LCD object named lcd, which will be used to control the display throughout the program.

👉 Initialize the LCD

  lcd.init();
  lcd.backlight();
  • Initializes the LCD and internally:
    • Starts I2C communication
    • Configures the LCD controller
  • This step is mandatory before using any LCD functions.
  • Enables the LCD backlight so text becomes visible.

!!! Note: The I2C pins (SDA & SCL) are automatically handled by the Wire library.

👉 Display Content

  lcd.setCursor(0, 0);
  lcd.print("Welcome to");
  lcd.setCursor(0, 1);
  lcd.print("Aavishkarah");
  delay(3000);
  • lcd.setCursor(0,0) Positions the cursor at:
    • Column 0
    • Row 0 (first row)
  • LCD row numbering starts from 0, not 1.
  • lcd.print Displays the text “Welcome to” starting from the first column of the first row.
  • lcd.setCursor(0,1) Moves the cursor to:
    • Column 0
    • Row 1 (second row)
  • lcd.printDisplays “Aavishkarah” on the second line of the LCD.
  • delay(3000) Pauses execution for 3000 milliseconds (3 seconds).
  • Keeps the welcome message visible before entering the loop.

👉 Display 0-9 continuously

  for(int i = 0; i < 10; i++) {
    lcd.clear();
    lcd.print(i);
    delay(1500);
  }
  • for loop
    • Initializes a variable i
    • Counts from 0 to 9
  • lcd.clear()
    • Clears the entire LCD screen.
    • Prevents overlapping of previous characters.
  • lcd.print(i)
    • Prints the current value of i on the LCD.
    • Numbers appear one by one (0 → 9).
  • delay(1500)
    • Holds each number on the display for 1.5 seconds.
  • After displaying 9, the loop restarts from 0.
  • Creates an infinite counting display on the LCD.

Try It

  • Alter the output content on the display by passing your data argument to the lcd.print() method.

Simulation

Not able to view the simulation

  • Desktop or Laptop : Reload this page ( Ctrl+R )
  • Mobile : Use Landscape Mode and reload the page
🛠️
Get the right hardware kit
Arduino boards, sensors, and maker essential Kits—perfectly matched for your learning.
Explore Hardware →

Extras

Components details

Modules / Libraries Used

  • LiquidCrystal_I2C.h
    • It provides ready-to-use functions to control 16×2 I2C LCD displays such as print(), clear(), setCursor() etc.,
    • More info
    • Github Source Code