Arduino 20x4 I2C LCD: Wiring, Code and Simulator

To build this Arduino 20x4 I2C LCD project you need an Arduino Uno and a 20x4 LCD. A 20×4 character LCD with an I²C backpack: four wires instead of twelve, LiquidCrystal_I2C at 0x27. Make the 4 connections in the wiring table, upload the Arduino C++ code, and compare with the 16×2 example: same controller, but SDA (A4) and SCL (A5) carry everything.

Open this circuit in the free Arduino Uno simulator

Parts list

QtyPartWhat it does
1Arduino Unothe microcontroller board
120x4 LCDFour rows of twenty characters. Same wiring as the 16×2; begin(20, 4) in the sketch.

Wiring

#FromTo
1Arduino Uno GND20x4 LCD GND
2Arduino Uno 5V20x4 LCD VCC
3Arduino Uno A420x4 LCD SDA
4Arduino Uno A520x4 LCD SCL

Step by step

  1. Open the simulator. Open the BitForBytes Embedded Lab in your browser and start from the Arduino Uno. No install or account is needed.
  2. Add the parts. Add a 20x4 LCD from the parts palette.
  3. Wire 1. Connect Arduino Uno GND to 20x4 LCD GND.
  4. Wire 2. Connect Arduino Uno 5V to 20x4 LCD VCC.
  5. Wire 3. Connect Arduino Uno A4 to 20x4 LCD SDA.
  6. Wire 4. Connect Arduino Uno A5 to 20x4 LCD SCL.
  7. Paste the Arduino C++ code. Paste the Arduino C++ code below into the code editor.
  8. Run it. Press Run. Compare with the 16×2 example: same controller, but SDA (A4) and SCL (A5) carry everything.

Arduino C++ code

// LCD over I2C: a 20x4 display on just two data wires (SDA = A4, SCL = A5),
// through a PCF8574 backpack at address 0x27.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 20, 4);

void setup() {
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("BitForBytes lab");
  lcd.setCursor(0, 1);
  lcd.print("I2C: only 4 wires");
}

void loop() {
  lcd.setCursor(0, 3);
  lcd.print("Uptime: ");
  lcd.print(millis() / 1000);
  lcd.print(" s");
  delay(250);
}

What to try

Compare with the 16×2 example: same controller, but SDA (A4) and SCL (A5) carry everything.

Frequently asked questions

How do I wire the 20x4 I2C LCD project on an Arduino Uno?

Make 4 connections: Arduino Uno GND to 20x4 LCD GND; Arduino Uno 5V to 20x4 LCD VCC; Arduino Uno A4 to 20x4 LCD SDA; Arduino Uno A5 to 20x4 LCD SCL.

What parts do I need for this Arduino project?

An Arduino Uno and a 20x4 LCD.

Can I simulate this Arduino project online for free?

Yes. The BitForBytes Embedded Lab runs this exact circuit and Arduino C++ code in your browser for free, with no install and no hardware. The sketch is compiled with the real Arduino toolchain and runs on an emulated ATmega328P.

What does the code do?

A 20×4 character LCD with an I²C backpack: four wires instead of twelve, LiquidCrystal_I2C at 0x27.

More Arduino Uno projects