Arduino LCD 16x2 Display Code (LiquidCrystal)
hardDisplaysArduino (C++)
A 16x2 LCD shows 2 rows of 16 characters — the most common display in PR-4 projects.
The question
Using the LiquidCrystal library with pins RS=12, E=11, D4=5, D5=4, D6=3, D7=2, show "Temp Monitor" on the first row and "Starting..." on the second row.
The sketch
sketch.ino
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
lcd.begin(16, 2);
lcd.print("Temp Monitor");
lcd.setCursor(0, 1);
lcd.print("Starting...");
}
void loop() {
}Wiring
LCD: RS → 12, E → 11, D4 → 5, D5 → 4, D6 → 3, D7 → 2, VSS/RW/K → GND, VDD/A → 5V.
How it works
- 1#include <LiquidCrystal.h> loads the library.
- 2LiquidCrystal lcd(12, 11, 5, 4, 3, 2) tells it which pins are RS, E and D4–D7.
- 3lcd.begin(16, 2) sets the size; lcd.print() writes text.
- 4lcd.setCursor(0, 1) moves to column 0 of the second row — rows are counted from 0.
Common mistakes
- Writing setCursor(1, 0) for the second row — the column comes first.
- Printing more than 16 characters on a row, which runs off the screen.
Now solve a similar question yourself
A new Arduino question every time, checked instantly.
