মূল বিষয়বস্তুতে যান
Learn/Displays/16×2 LCD over I²C
Displays · Lesson
10 min read

16×2 LCD over I²C

Show text with only two signal wires.

What You Will Learn

  • Wire an I²C LCD
  • Position the cursor
  • Avoid leftover characters

Character LCDs need many wires, but an I²C 'backpack' reduces them to four: VCC, GND, SDA (data) and SCL (clock). On the Uno, SDA is A4 and SCL is A5; on the ESP32, GPIO21 and GPIO22.

Arduino C++
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0, 0);   // column 0, row 0
  lcd.print("Hello, Labs!");
}
Text stays until overwritten. Print a few spaces after changing numbers ("27 C ") so old digits don't remain.
LCD thermometerarduino-uno
Open in Lab
UNOATmega328P: The 8-bit AVR microcontroller that runs your sketch (16 MHz, 32 KB flash, 2 KB RAM).ATmega328PUSB-B: USB connection for uploading sketches and for the Serial Monitor. Also powers the board (5 V).DC jack: Barrel jack for 7–12 V from a battery pack or adapter (centre positive).ATmega16U2: Converts USB to serial for uploads and Serial.print().RESET: Restarts your sketch from the beginning (setup() runs again).L (D13): Built-in LED connected to pin 13 (LED_BUILTIN).ON: Power indicator.5 V regulator: Turns 7–12 V from VIN/jack into a steady 5 V.16 MHz: Clock source: the microcontroller runs 16 million cycles per second.ICSP: In-circuit programming header (SPI). Used to burn a bootloader; not needed for normal uploads.27°C · 60%GNDVCCSDASCL
Most backpacks use address 0x27; some use 0x3F. An I²C scanner sketch finds the right one on real hardware.

Check Your Understanding

Test what you learned in this lesson

1Which Uno pins are SDA and SCL?