All Articles
ArduinoMarch 22, 2026•6 min read•TheBotBakers Team

How to Interface a 16x2 I2C LCD with Arduino: Wiring, Code & Troubleshooting

Save up to 12 precious Arduino pins using the PCF8574 I2C adapter backpack. Follow our wiring guide, address scanner, and troubleshooting tips to display sensor telemetry on a 16x2 character LCD.
How to Interface a 16x2 I2C LCD with Arduino: Wiring, Code & Troubleshooting

Standard 16x2 Character LCD displays require at least 6 digital pins in 4-bit mode (RS, EN, D4, D5, D6, D7), plus contrast and backlight wiring. This quickly consumes the majority of your Arduino Uno's I/O pins, leaving very little room for sensors, buzzers, or motor drivers.

By using an I2C Serial Interface Backpack (PCF8574T), you can drive the entire display using only 4 wires: Power (5V), Ground (GND), and 2 I2C communication lines (SDA and SCL).

Pinout & Connection Diagram

The I2C backpack features a simple 4-pin header:

  • GND -> Connect to Arduino GND
  • VCC -> Connect to Arduino 5V power rail
  • SDA (Serial Data) -> Connect to Arduino A4 (or dedicated SDA pin next to AREF)
  • SCL (Serial Clock) -> Connect to Arduino A5 (or dedicated SCL pin next to AREF)

Required Components

  • 1x 16x2 Character LCD with pre-soldered I2C backpack
  • 1x Arduino Uno R3 or Nano
  • 4x Female-to-Male DuPont jumper wires
  • 1x USB programming cable

Step 1: Discovering Your Display's I2C Address

Most I2C backpacks use either hex address 0x27 or 0x3F depending on the onboard PCF8574 chip variant. To guarantee your sketch connects properly on the first attempt, upload an I2C scanner:

cppTheBotBakers Example
#include <Wire.h>

void setup() {
  Wire.begin();
  Serial.begin(9600);
  Serial.println("\nScanning I2C Bus...");
}

void loop() {
  byte error, address;
  int nDevices = 0;
  for (address = 1; address < 127; address++) {
    Wire.beginTransmission(address);
    error = Wire.endTransmission();
    if (error == 0) {
      Serial.print("I2C device found at address 0x");
      if (address < 16) Serial.print("0");
      Serial.print(address, HEX);
      Serial.println(" !");
      nDevices++;
    }
  }
  if (nDevices == 0) Serial.println("No I2C devices found\n");
  delay(5000);
}

Open the Serial Monitor at 9600 baud. Note the address displayed (typically 0x27 or 0x3F).

Step 2: Installing the LiquidCrystal_I2C Library

  1. In the Arduino IDE menu, navigate to Sketch > Include Library > Manage Libraries...
  2. In the search box, type LiquidCrystal I2C (by Frank de Brabander or Marco Schwartz).
  3. Click Install.

Step 3: Example Code to Display Text & Counter

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

// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);

int counter = 0;

void setup() {
  lcd.init();          // Initialize the LCD
  lcd.backlight();     // Turn on backlight
  
  lcd.setCursor(0, 0); // Column 0, Row 0
  lcd.print("TheBotBakers BD");
  lcd.setCursor(0, 1); // Column 0, Row 1
  lcd.print("Robotics & STEM");
  delay(2500);
  lcd.clear();
}

void loop() {
  lcd.setCursor(0, 0);
  lcd.print("Status: Active");
  
  lcd.setCursor(0, 1);
  lcd.print("Count: ");
  lcd.print(counter);
  
  counter++;
  delay(1000);
}

Troubleshooting Common LCD Issues

  • Screen is blank or shows black rectangular blocks: Use a small flathead screwdriver to gently rotate the blue contrast potentiometer on the back of the I2C backpack until the letters appear crisp and clear.
  • Backlight is on but no text appears: Verify whether your I2C address is 0x3F rather than 0x27 using the scanner sketch above.
  • Garbled characters: Make sure your SDA and SCL jumper wires are firmly seated and that the Arduino 5V supply is not dropping below 4.7V.
#Arduino#16x2 LCD#I2C Backpack#PCF8574#Display#Tutorial
Hands-on Robotics Hardware

Ready to Build This Project?

Get all required genuine microcontrollers, sensors, and starter kits with fast delivery across Bangladesh (80 ৳ inside Dhaka, 120 ৳ nationwide).

More Tutorials & Articles

Keep exploring electronics, Arduino, and robotics guides.

View All