16x2 LCD Hello World
Display text on a 16x2 character LCD.
- Intermediate
- Displays
- 2 parts
Opens in your browser with the parts, wiring and code already in place. Press Run to watch it work, then change anything you like.
How it works
A 16×2 character LCD shows two rows of 16 characters. It is wired here in 4-bit mode: RS (register select) on pin 12 and E (enable) on pin 11 tell the display whether a command or a character is arriving, and four data lines, D4 to D7 on pins 5, 4, 3 and 2, carry each character four bits at a time. VCC and GND power it.
The LiquidCrystal library hides that signalling. LiquidCrystal lcd(12, 11, 5, 4, 3, 2) lists the pins in the order RS, E, D4, D5, D6, D7. setup() starts a 16-column, 2-row display with lcd.begin(16, 2), prints “Hello, World!” on the first row, moves to the start of the second row with setCursor(0, 1) and prints “CYTHEIA”. loop() then updates a seconds counter at column 10 of the second row, once a second.
Parts
- Arduino Uno
- LCD 16x2
Wiring
- Arduino Uno 5V → LCD 16x2 VCC
- Arduino Uno GND → LCD 16x2 GND
- Arduino Uno D12 → LCD 16x2 RS
- Arduino Uno D11 → LCD 16x2 E
- Arduino Uno D5 → LCD 16x2 D4
- Arduino Uno D4 → LCD 16x2 D5
- Arduino Uno D3 → LCD 16x2 D6
- Arduino Uno D2 → LCD 16x2 D7
Arduino code
// 16x2 LCD Hello World
#include <LiquidCrystal.h>
// The pins wired to the display: RS, E, D4, D5, D6, D7
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
lcd.begin(16, 2);
lcd.print("Hello, World!");
lcd.setCursor(0, 1);
lcd.print("CYTHEIA");
Serial.begin(9600);
Serial.println("LCD ready");
}
void loop() {
// A live clock in the corner of the second row
lcd.setCursor(10, 1);
lcd.print(millis() / 1000);
lcd.print("s");
delay(1000);
}
Try changing it
- Change the message: edit the text in lcd.print("Hello, World!"). A row holds 16 characters, so keep it short.
- If you move a wire in the editor, change the matching number in the LiquidCrystal line too: the pins are listed in the order RS, E, D4, D5, D6, D7.