I2C LCD Code Generator
Generate ready-to-use LiquidCrystal_I2C code for your Arduino I2C LCD in seconds. Pick the size, address and text, then copy the sketch.
Note: use plain ASCII, most character LCDs do not render accented letters.
What Is an Arduino I2C LCD and How to Use It?
An I2C LCD is a standard 16x2 or 20x4 character display with a PCF8574 I2C backpack soldered to the back. A normal LCD needs six or more digital pins, while an I2C LCD works with just two data pins (SDA and SCL). This tool generates a ready-to-run LiquidCrystal_I2C sketch from your size, I2C address and text. Everything runs in your browser.
Wiring (Arduino Uno)
- VCC → 5V
- GND → GND
- SDA → A4
- SCL → A5
On the Arduino Mega, SDA is pin 20 and SCL is pin 21.
Can't Find the I2C Address? (I2C Scanner)
If you do not know your module's address, upload the scanner sketch below and open the Serial Monitor (9600 baud). Enter the address it reports into the I2C Address box above.
#include <Wire.h>
void setup() {
Wire.begin();
Serial.begin(9600);
Serial.println("I2C scanner started...");
for (byte a = 1; a < 127; a++) {
Wire.beginTransmission(a);
if (Wire.endTransmission() == 0) {
Serial.print("Device found: 0x");
Serial.println(a, HEX);
}
}
}
void loop() {}Frequently Asked Questions
How do I find my I2C LCD address?
Most modules use 0x27 or 0x3F. If unsure, upload the I2C scanner sketch above and read the address from the Serial Monitor.
Which library do I need?
Install the LiquidCrystal_I2C library from the Arduino IDE Library Manager. Wire.h ships with the IDE.
Nothing shows on the screen, what should I do?
Adjust the contrast with the blue potentiometer on the back of the module, and double-check the address and the SDA/SCL wiring.