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
| Qty | Part | What it does |
|---|---|---|
| 1 | Arduino Uno | the microcontroller board |
| 1 | 20x4 LCD | Four rows of twenty characters. Same wiring as the 16×2; begin(20, 4) in the sketch. |
Wiring
| # | From | To |
|---|---|---|
| 1 | Arduino Uno GND | 20x4 LCD GND |
| 2 | Arduino Uno 5V | 20x4 LCD VCC |
| 3 | Arduino Uno A4 | 20x4 LCD SDA |
| 4 | Arduino Uno A5 | 20x4 LCD SCL |
Step by step
- Open the simulator. Open the BitForBytes Embedded Lab in your browser and start from the Arduino Uno. No install or account is needed.
- Add the parts. Add a 20x4 LCD from the parts palette.
- Wire 1. Connect Arduino Uno GND to 20x4 LCD GND.
- Wire 2. Connect Arduino Uno 5V to 20x4 LCD VCC.
- Wire 3. Connect Arduino Uno A4 to 20x4 LCD SDA.
- Wire 4. Connect Arduino Uno A5 to 20x4 LCD SCL.
- Paste the Arduino C++ code. Paste the Arduino C++ code below into the code editor.
- 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
- Arduino LED Blink: Wiring, Code and Simulator
- Arduino LDR Light Sensor: Wiring, Code and Simulator
- Arduino NTC Thermistor Thermometer: Wiring, Code and Simulator
- Arduino PWM to Analog RC Filter: Wiring, Code and Simulator
- Arduino Capacitance Meter: Wiring, Code and Simulator
- Arduino DC Motor PWM Speed Control with MOSFET: Wiring, Code and Simulator