/tools/lcd-custom-character
1602 custom characters
A 1602 or a 2004 has sixty-four bytes of character RAM, which is eight glyphs of your own and not a ninth. Draw them here — the grid is the part nobody can do in their head — and the sketch comes out underneath in whichever language you are writing.
Slot — 1 of 8 used
Start from one of these
Slot 0 of eight, as the library wants it. The array is the picture above, one row a byte, and only the low five bits of each are drawn.
// Tools ▸ Board: your ESP32 · Port: the one that appears when you plug it in
// Library: LiquidCrystal_I2C (or LiquidCrystal for a parallel 1602)
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
byte heart[8] = {
B00000,
B01010,
B11111,
B11111,
B11111,
B01110,
B00100,
B00000,
};
void setup() {
lcd.init();
lcd.backlight();
lcd.createChar(0, heart);
lcd.setCursor(0, 0);
// byte(0), not 0: a bare 0 is NUL and prints nothing.
lcd.write(byte(0));
}
void loop() {}lcd.write(byte(0)) and not lcd.write(0): a bare zero is NUL, the compiler picks the numeric overload, and nothing appears on the screen with no error anywhere. Slots 0–7 are also mirrored at 8–15 if a zero in your string is awkward.
More in screens and pixels
What a display asks of your supply, your bus and your patience.