I2C LCD1602 Arduino Tutorial: Wire the Display With Two Pins and Show Text, Numbers and Custom Characters
The LCD1602 is a character display with two rows of 16 characters, and it is one of the most common displays in Arduino projects. Used on its own it needs at least six Arduino pins, but a small I2C backpack on the back of the module reduces the connection to two signal wires, SDA and SCL. This tutorial shows how to wire the module, find its I2C address, install the LiquidCrystal_I2C library and print text, numbers and scrolling messages. It also explains how to build custom characters in the display memory.
Every example is a complete sketch, and a troubleshooting table and a short FAQ at the end cover the problems that readers most often meet. The sketches were written for the Arduino Uno and also apply to the Nano and the Mega with the pin changes that the wiring section lists.
This guide belongs to the Arduino Display Interfacing Tutorials series. The bus itself is explained in the Arduino I2C tutorial, and readers who want a graphic screen instead of a character display can continue with the SSD1306 OLED tutorial or the SH1106 OLED tutorial.
Table of contents
I2C LCD1602 Overview
An I2C LCD1602 is a standard 16 x 2 character LCD with a small I2C adapter board, called a backpack, soldered to its back. The display shows 16 characters in each of two rows, and each character is a 5 x 8 pixel cell. The LCD uses the HD44780 controller or a compatible one, which most Arduino libraries support.
Parallel and I2C Interface
The bare LCD1602 has a parallel interface. In 8-bit mode it needs eight data lines and three control lines, which makes 11 pins, and in 4-bit mode it needs four data lines and two control lines, which makes 6 pins. Those pins are not available for sensors and other modules on a small board. The I2C backpack moves the connection onto the two-wire I2C bus, and the same SDA and SCL lines can serve other I2C devices as well.
PCF8574 I/O Expander
Most backpacks use the PCF8574 or the PCF8574A, which is an 8-bit I/O expander with an I2C interface. The chip receives bytes over I2C and sets its eight outputs accordingly, and those outputs drive the data, control and backlight lines of the LCD. The backpack also carries a blue potentiometer that sets the contrast and a jumper that connects the backlight.
PCF8574 and PCF8574A Variants
The two chips work the same way and differ only in the base I2C address. The PCF8574 answers at addresses from 0x20 to 0x27, and the PCF8574A answers at addresses from 0x38 to 0x3F. The common default addresses are 0x27 for the PCF8574 and 0x3F for the PCF8574A, so a module that does not respond at 0x27 is often the second type. The address section shows how to find the exact value.
I2C LCD1602 Wiring with Arduino
The module connects to the Arduino with four wires. Connect VCC to 5V, GND to GND, SDA to the SDA pin of the board and SCL to the SCL pin of the board. The parts for this tutorial are an Arduino board, an I2C LCD1602 module and four jumper wires.
| I2C LCD1602 pin | Arduino Uno pin | Description |
|---|---|---|
| VCC | 5V | Power for the LCD and the backpack |
| GND | GND | Common ground |
| SDA | A4 | I2C data line |
| SCL | A5 | I2C clock line |
The I2C pins depend on the board.
| Board | SDA pin | SCL pin |
|---|---|---|
| Arduino Uno and Nano | A4 | A5 |
| Arduino Mega | 20 | 21 |
| Arduino Leonardo and Micro | 2 | 3 |
The Arduino UNO pinout guide and the Arduino Nano pinout guide show the full pin layout of each board.
LCD1602 Power Requirements
A standard LCD1602 module is designed for a 5 V supply, and the backlight and the backpack draw their current from the same pin. The supply current is typically a few tens of milliamps with the backlight on, and the exact value depends on the module. A module that is powered from 3.3 V usually shows faint or invisible characters, because the contrast voltage is too low, unless it is a 3.3 V version of the display.
The backpack also pulls SDA and SCL up to its own supply voltage. On a 3.3 V board such as the ESP32 or the Due, a 5 V powered backpack therefore puts 5 V on the I2C lines, which can damage the board. Those boards need a level shifter or a module that is built for 3.3 V.
I2C LCD1602 Address and Scanner
Every I2C device answers at a 7-bit address, and the sketch must use the address of the connected module. The backpack address is 0x27 on many modules and 0x3F on others, and a scanner sketch finds the correct value.
Find the I2C Address with a Scanner
The scanner tries every address from 1 to 126 and prints each address that acknowledges.
#include <Wire.h>
void setup() {
Wire.begin();
Serial.begin(9600);
Serial.println("Scanning for I2C devices...");
uint8_t found = 0;
for (uint8_t address = 1; address < 127; address++) {
Wire.beginTransmission(address);
if (Wire.endTransmission() == 0) { // 0 means a device acknowledged
Serial.print("I2C device found at address 0x");
Serial.println(address, HEX);
found++;
}
}
if (found == 0) {
Serial.println("No I2C device found. Check the wiring.");
}
}
void loop() {
}Open the Serial Monitor at 9600 baud. A module with a PCF8574 usually reports 0x27, and one with a PCF8574A usually reports 0x3F.
Change the Address with A0, A1 and A2
The backpack has three solder pads named A0, A1 and A2, and they set the lower three bits of the address. On most backpacks the pads are open and pulled up, which gives the highest address of the range, 0x27 or 0x3F. Soldering a bridge across a pad connects that address line to GND and clears its bit. Two displays on the same bus can therefore work together when each has a different pad setting.
| A2 | A1 | A0 | PCF8574 address | PCF8574A address |
|---|---|---|---|---|
| 0 | 0 | 0 | 0x20 | 0x38 |
| 0 | 0 | 1 | 0x21 | 0x39 |
| 0 | 1 | 0 | 0x22 | 0x3A |
| 0 | 1 | 1 | 0x23 | 0x3B |
| 1 | 0 | 0 | 0x24 | 0x3C |
| 1 | 0 | 1 | 0x25 | 0x3D |
| 1 | 1 | 0 | 0x26 | 0x3E |
| 1 | 1 | 1 | 0x27 | 0x3F |
In the table a value of 1 means an open pad and a value of 0 means a pad that is bridged to GND. Bridging only A0 on a module that starts at 0x27 therefore moves it to 0x26.
I2C LCD1602 Library Setup
The LiquidCrystal_I2C library sends the HD44780 commands through the PCF8574, and it uses the Wire library that ships with the Arduino IDE. Open the Library Manager, search for LiquidCrystal I2C and install the version by Frank de Brabander. Other libraries share the same name, and some of them start the display with lcd.begin() instead of lcd.init(), so the sketches in this guide are written for the library named above.
LiquidCrystal_I2C Functions
| Function | Syntax | What it does |
|---|---|---|
| init | lcd.init(); | Initializes the LCD, and it must run in setup() before any output. |
| backlight | lcd.backlight(); | Turns the backlight on. |
| noBacklight | lcd.noBacklight(); | Turns the backlight off. |
| clear | lcd.clear(); | Clears the display and moves the cursor to column 0 of row 0. |
| home | lcd.home(); | Moves the cursor to column 0 of row 0 without clearing the display. |
| setCursor | lcd.setCursor(col, row); | Moves the cursor to a column from 0 to 15 and a row from 0 to 1. |
lcd.print(value); | Prints text, integers and floats at the cursor. | |
| write | lcd.write(code); | Writes one character code, which is used for custom characters. |
| scrollDisplayLeft | lcd.scrollDisplayLeft(); | Shifts the whole display one position to the left. |
| scrollDisplayRight | lcd.scrollDisplayRight(); | Shifts the whole display one position to the right. |
| createChar | lcd.createChar(slot, data); | Stores a custom character in one of the slots 0 to 7. |
| cursor, noCursor | lcd.cursor(); | Shows or hides the underline cursor. |
| blink, noBlink | lcd.blink(); | Starts or stops the blinking block cursor. |
I2C LCD1602 Text and Numbers
The setCursor() function chooses where the next character appears, and print() writes the text or the number at that position. The columns are numbered from 0 to 15 and the rows from 0 to 1.
Display Text on the LCD1602
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Use the address found by the scanner. The size is 16 columns and 2 rows.
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
lcd.init(); // initialize the LCD
lcd.backlight(); // turn on the backlight
lcd.setCursor(0, 0); // column 0, row 0
lcd.print("Hello, World!");
lcd.setCursor(0, 1); // column 0, row 1
lcd.print("I2C LCD1602");
}
void loop() {
}A string longer than 16 characters runs past the visible area, and the extra characters stay in the display memory without wrapping to the next row.
Display Integer, Float and Hex Values
The print() function formats numbers as well. A second argument sets the number of decimal places for a float, or the number base for an integer.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
lcd.init();
lcd.backlight();
int number = 1234;
float voltage = 5.123;
lcd.setCursor(0, 0);
lcd.print("Int: ");
lcd.print(number); // prints 1234
lcd.setCursor(0, 1);
lcd.print("Float: ");
lcd.print(voltage, 2); // two decimal places, prints 5.12
delay(3000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Hex: 0x");
lcd.print(number, HEX); // 1234 in hexadecimal is 4D2
}
void loop() {
}The DHT11 and DHT22 tutorial and the BME280 tutorial both show measured values on this display.
I2C LCD1602 Scrolling Text
The LCD stores up to 40 characters for each row, while the screen shows a window of 16 of them. The scrollDisplayLeft() and scrollDisplayRight() functions move that window by one position, so a message that is longer than 16 characters becomes readable. The scroll acts on both rows at the same time, because the controller shifts the whole display.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Scrolling Message Demo"); // 22 characters, so only 16 are visible at first
delay(1000);
}
void loop() {
for (uint8_t i = 0; i < 20; i++) { // move the window to the left
lcd.scrollDisplayLeft();
delay(300); // a larger delay gives slower scrolling
}
delay(1000);
for (uint8_t i = 0; i < 20; i++) { // move the window back to the right
lcd.scrollDisplayRight();
delay(300);
}
delay(1000);
}The delay inside the loops sets the scroll speed. A sketch that has to do other work while the text moves can replace delay() with a millis() timer that calls the scroll function once per interval.
I2C LCD1602 Custom Characters
The LCD stores its built-in characters in ROM, and it also has a small writable memory called CGRAM for characters that the sketch defines. This memory holds eight custom characters, numbered 0 to 7, which is enough for icons such as a heart, an arrow or a degree sign.
How CGRAM Characters Work
Each custom character is a grid of 5 columns and 8 rows. A character is stored as an array of 8 bytes, one byte for each row, and the lower 5 bits of each byte are the pixels of that row. A bit that is set to 1 lights the pixel, and a bit that is set to 0 leaves it dark. The last row is normally left empty, because the cursor is drawn in that row.
The createChar() function stores the array in a slot, and write() shows the character from that slot on the screen. The slot number must be written as byte(0) and not as a plain 0, because a plain 0 can be mistaken for a null pointer by older Arduino versions. Custom characters must be created again after a reset, so the calls belong in setup().
| Binary row | Hex value | Pixels |
|---|---|---|
0b00000 | 0x00 | empty row |
0b01010 | 0x0A | two dots for the eyes |
0b10001 | 0x11 | the ends of the smile |
0b01110 | 0x0E | the bottom of the smile |
Single Custom Character Example
The sketch stores a smiley face in slot 0 and shows it below a line of text.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
// Smiley face, one byte for each of the 8 rows
byte smiley[8] = {
0b00000,
0b01010,
0b01010,
0b00000,
0b10001,
0b01110,
0b00000,
0b00000
};
void setup() {
lcd.init();
lcd.backlight();
lcd.createChar(0, smiley); // store the character in slot 0
lcd.setCursor(0, 0);
lcd.print("Have a nice day ");
lcd.setCursor(7, 1); // column 7 of row 1, near the middle of the screen
lcd.write(byte(0)); // show the character from slot 0
}
void loop() {
}Multiple Custom Characters Example
The next sketch stores five characters in slots 0 to 4 and writes them side by side on the second row.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
// Five custom characters, 5 x 8 pixels each
byte char1[8] = {0x00, 0x0A, 0x0A, 0x00, 0x11, 0x0E, 0x00, 0x00}; // smiley
byte char2[8] = {0x04, 0x0E, 0x15, 0x04, 0x04, 0x04, 0x04, 0x00}; // arrow up
byte char3[8] = {0x04, 0x04, 0x04, 0x04, 0x15, 0x0E, 0x04, 0x00}; // arrow down
byte char4[8] = {0x00, 0x0A, 0x0A, 0x0A, 0x11, 0x0E, 0x00, 0x00}; // second smiley
byte char5[8] = {0x00, 0x04, 0x0E, 0x1F, 0x0E, 0x04, 0x00, 0x00}; // heart
void setup() {
lcd.init();
lcd.backlight();
lcd.createChar(0, char1); // slots 0 to 4
lcd.createChar(1, char2);
lcd.createChar(2, char3);
lcd.createChar(3, char4);
lcd.createChar(4, char5);
lcd.setCursor(0, 0);
lcd.print("Have a nice day ");
lcd.setCursor(6, 1); // the five characters fill columns 6 to 10
for (uint8_t slot = 0; slot < 5; slot++) {
lcd.write(byte(slot));
}
}
void loop() {
}Custom Character Generator
The original post includes an interactive 5 x 8 pixel grid that produces the byte array for a drawn character. It is a script on the page and did not come through in the fetch, so it has to be added back here. Without the tool, each row of the drawing is written as a 5-digit binary number with the prefix 0b, and the eight rows form the array.
I2C LCD1602 Troubleshooting
Most problems with an I2C LCD1602 come from the contrast setting, the I2C address or the wiring, and the table lists the common symptoms with their causes and fixes.
| Symptom | Likely cause | Fix |
|---|---|---|
| The backlight is on but no text appears. | The contrast is set too low, or too high. | Turn the blue potentiometer on the backpack slowly until the characters appear. |
| The first row shows solid blocks and the second row is empty. | The display is powered but not initialized, or the contrast is too high. | Check that lcd.init() runs in setup() and lower the contrast. |
| The screen and the backlight stay off. | The backlight jumper is missing, or the module has no power. | Fit the jumper, call lcd.backlight() and check the 5V and GND wires. |
| The scanner finds no device. | SDA and SCL are swapped or loose, or the module is not powered. | Check the four wires and the pins of the board that is used. |
| The sketch compiles but the LCD stays blank. | The address in the sketch differs from the real one. | Run the scanner and write the address it reports in the LiquidCrystal_I2C line. |
The compiler reports that init is not a member of the library. | A different library with the same name is installed. | Use the library by Frank de Brabander or change the call to match the installed one. |
| The text is faint or unreadable on a 3.3 V supply. | The LCD needs about 5 V for a good contrast. | Power the module from 5 V, and use a level shifter on a 3.3 V board. |
| A custom character shows as a wrong symbol or nothing. | The slot is written as 0 or the character was not created. | Use lcd.write(byte(slot)) and call createChar() in setup(). |
| A text line shows only 16 characters. | The string is longer than the visible area. | Shorten the string or use the scroll functions. |
Conclusion
An I2C backpack reduces the LCD1602 to two signal wires and a power connection, and the LiquidCrystal_I2C library makes the display as easy to use as the Serial Monitor. The address of the backpack is the most important setting, and the scanner sketch finds it in a few seconds. The print() function formats text, integers, floats and hexadecimal values, and createChar() adds up to eight custom symbols.
The display needs a 5 V supply for a readable contrast, and its I2C lines then also run at 5 V, which matters on 3.3 V boards. A troubleshooting check that starts with the contrast potentiometer and the address solves most of the problems that appear.
The LCD1602 pairs well with the sensor tutorials of the series. The DS3231 real-time clock tutorial, the HC-SR04 distance sensor tutorial and the BMP180 pressure sensor tutorial all show their readings on this display. Readers who need a graphic display can continue with the SSD1306 OLED tutorial.
Download Project Here
Download the CubeMX project files and HAL source code — all tested on real hardware.
If you find this useful, you can support us with a Donation as well.
Browse More Arduino Display Tutorials

Arun is an embedded systems engineer with 10+ years of experience in STM32, ESP32, and AVR microcontrollers. He created ControllersTech to share practical tutorials on embedded software, HAL drivers, RTOS, and hardware design — grounded in real industrial automation experience.
Recommended Tools
Essential dev tools
Categories
Browse by platform











