Skip to main content

wokwi-lcd1602 Reference

An LCD with 2 lines, 16 characters per line.

Pin names

The LCD1602 comes in 2 possible configurations: I2C configuration and standard configuration. The I2C configuration is usually simpler to use.

The following table summarizes the key differences:

PropertyStandardI2C
Number of Arduino I/O pins7*2 (SCL)/SDA
Backlight controlOptionalYes
Library nameLiquidCrystalLiquidCrystal_I2C

* Controlling the backlight requires another I/O pin.

You can select the desired configuration by setting the pins attribute. Set it to "i2c" for the I2C configuration, or "full" for the standard configuration (the default).

I2C configuration

NameDescription
GNDGround
VCCSupply voltage
SDAI2C data line
SCLI2C clock line

The default I2C address of the LCD1602 module is 0x27.

Note: The I2C configuration simulates a PCF8574T chip that controls the LCD module. Normally, you wouldn't have to worry about this as the LiquidCrystal_I2C library takes care of the communication with the chip.

Standard configuration

NameDescriptionArduino Pin*
VSSGroundGND.1
VDDSupply voltage5V
V0Contrast adjustment (not simulated)
RSCommand/Data select12
RWRead/Write. Connect to Ground.GND.1
EEnable11
D0Parallel data 0 (optional) †
D1Parallel data 1 (optional) †
D2Parallel data 2 (optional) †
D3Parallel data 3 (optional) †
D4Parallel data 410
D5Parallel data 59
D6Parallel data 68
D7Parallel data 77
ABacklight anode5V / 6‑
KBacklight cathodeGND.1

* These are just example pin numbers, they are not mandatory. You need can use any digital/analog pin, but make sure to update the code accordingly!
† Normally, you'd configure the chip in 4-bit parallel mode, which means you only need to connect RS, E, D4, D5, D6, and D7 pins to Arduino.
‑ If you need to control the backlight, connect the anode to an I/O pin. Otherwise, connect it to the supply voltage. For a real circuit, you'd also need a current-limiting resistor, but you may skip it in the simulation environment.

Arduino code example

When you initialize the LiquidCrystal library in your code, you need to pass the pin numbers to the constructor.

The following example uses pin numbers that match the table above:

#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 10, 9, 8, 7);

void setup() {
lcd.begin(16, 2);
// you can now interact with the LCD, e.g.:
lcd.print("Hello World!");
}

void loop() {
// ...
}

You can also try this example on Wokwi.

Attributes

NameDescriptionDefault value
pinsSet to "i2c" for I2C configuration"full"
i2c-addressI2C address (I2C configuration)"0x27"
colorThe color of the text"black"
backgroundThe color of the backlight"green"

Examples

ResultAttrs
{ }
{ "pins": "i2c" }
{ "background": "blue", "color": "white" }

Font

The LCD1602 uses the Hitachi HD44780 LCD Controller chip. The chip comes with a built-in font, as well as the ability to define up to 8 custom characters.

There are two versions of the chip's ROM with two different fonts: HD44780UA00, which includes Japanese katakana characters, and HD44780UA02, which includes Western European characters.

Wokwi simulates the HD44780UA00 variant. It has a total of 256 characters:

RangeDescription
0-7User defined characters
8-31Blank characters
32-127Standard ASCII characters
128-160Blank characters
161-255Japanese katankana and symbols

ASCII character glyphs:

3233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127

High characters glyphs:

160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255

Note: if you need the HD44780UA02 font variant, please open a feature request or reach out on Discord.

User defined characters

You can define custom characters using the createChar method of the LiquidCrsytal (or LiquidCrystal_I2C) library. The custom characters are the first 8 characters in the font, with indexes from 0 to 7. You can print them to the LCD display using the write() method, or using C string escape sequence, such as "\x07".

The following code example defines a heart shaped character, stores it at index 3, and then uses it to display the text "I (heart) Arduino":

#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 10, 9, 8, 7);

uint8_t heart[8] = {
0b00000,
0b01010,
0b11111,
0b11111,
0b11111,
0b01110,
0b00100,
0b00000,
};

void setup() {
lcd.createChar(3, heart);
lcd.begin(16, 2);
lcd.print(" I \x03 Arduino");
}

void loop() { }

You can also run this example on Wokwi.

You can modify any custom character while the program is running. This method is useful for creating simple animations. For example, change loop() in the code sample above to slowly reveal the heart icon, line-by-line:

void loop() {
uint8_t heart2[8] = {0};
for (int i = 0; i < 8; i++) {
heart2[i] = heart[i];
lcd.createChar(3, heart2);
delay(100);
}
delay(500);
}

Simulator examples