CYTHEIA AIOpen the editor

16x2 LCD Hello World

Display text on a 16x2 character LCD.

Open this circuit and run it

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

Wiring

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

Open this circuit and run it

Next challenge

More projects in Displays