Menu
CoddyTech

Hello on the LCD

Part of the Displays and Sensors section of Coddy's Arduino journey. Lesson 6 of 24.

A character LCD shows text: this one has 2 rows of 16 characters. A chip on its back draws the letters, and the board tells it what to draw over six wires.

The LiquidCrystal library does the talking. Include it, then make an lcd object with the six pins, in this order: RS, E, D4, D5, D6 and D7.

#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

In setup(), lcd.begin(16, 2) tells the library the screen has 16 columns and 2 rows. Without it the library treats the screen as one row, and the bottom row stays blank.

lcd.print() then works like Serial.print(): text in quotes, or a number. Use print(), not println(): the screen has no idea what a new line is, and draws the two line-ending characters as junk.

challenge icon

Challenge

Easy

The LCD is wired to pins 12, 11, 5, 4, 3 and 2, and the starter makes the lcd object. In setup():

  • start the screen with lcd.begin(16, 2)
  • print Hello, world! with lcd.print()

Press Run to see it on the screen, then Check.

Try it yourself

#include <LiquidCrystal.h>

// RS, E, D4, D5, D6, D7
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  // start the screen and print the message here
}

void loop() {
}
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Displays and Sensors

Practice on your own: Arduino playground