Introduction
Standard 16x2 LCDs require many pins. By using an I2C adapter, you can control the entire display with just two data wires (SDA and SCL).
Components Required
- Arduino Uno
- 16x2 LCD with I2C Adapter
- Jumper wires
Wiring
| LCD (I2C) | Arduino |
|---|---|
| GND | GND |
| VCC | 5V |
| SDA | A4 |
| SCL | A5 |
Install Library
Search for LiquidCrystal I2C by Frank de Brabander in the Arduino Library Manager.
The Code
#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("Hello, ScienIoT!");
}
void loop() {
lcd.setCursor(0, 1);
lcd.print("Uptime: ");
lcd.print(millis() / 1000);
lcd.print("s");
delay(1000);
}Tips
- If the screen is blank, adjust the blue potentiometer on the back of the I2C module to set the contrast.
- The default I2C address is usually 0x27 or 0x3F.