LCD1602 on pins 4, 6 and 10 to 13, on an Arduino Uno
A 16x2 LCD with RS on pin 4, E on 6 and D4 to D7 on pins 10 to 13: the top line greets you and the bottom line scrolls a message across. The whole build, an Arduino Uno and 1 more part, runs here in your browser on the firmware below; open it in the editor to change the wiring or the code and run it again.
Teaching? Assign it to your class in one click.
Beginner Runs in your browser. Free, and no account needed.
The code
The firmware exactly as the editor opens it. Change a line there and press Run: it compiles in the browser.
// A 16x2 LCD on pins 4, 6 and 10 to 13.
//
// LCD RS -> pin 4 LCD E -> pin 6
// LCD D4 -> pin 10 D5 -> pin 11 D6 -> pin 12 D7 -> pin 13
// LCD RW, VSS, K -> GND VDD, A -> 5V
// LCD V0 (contrast) -> GND here; on the bench, the middle leg of a pot
//
// LiquidCrystal's constructor takes RS, E, D4, D5, D6 and D7, in that order.
// The top line shows a fixed greeting; the second line scrolls a message
// across one character at a time by printing it from a moving start column.
#include <LiquidCrystal.h>
LiquidCrystal lcd(4, 6, 10, 11, 12, 13);
const char MESSAGE[] = "Hello from the Uno! ";
int start = 0;
void setup() {
lcd.begin(16, 2);
lcd.print("Mokxi LCD1602");
Serial.begin(9600);
Serial.println("Mokxi Uno: LCD1602 on pins 4, 6 and 10 to 13");
}
void loop() {
int length = sizeof(MESSAGE) - 1;
lcd.setCursor(0, 1);
for (int i = 0; i < 16; i++) lcd.print(MESSAGE[(start + i) % length]);
start = (start + 1) % length;
delay(300);
}
Parts list
3 parts, plus the jumper wires. Every one is in the editor's parts bin.
How it is wired
8 connections, pin by pin, read from the circuit itself. Each line is one set of pins joined together, by a jumper wire or a breadboard strip.
- Arduino Uno R3 pin 13; Character LCD, 16x2 pin D7
- Arduino Uno R3 pin 12; Character LCD, 16x2 pin D6
- Arduino Uno R3 pin 11; Character LCD, 16x2 pin D5
- Arduino Uno R3 pin 10; Character LCD, 16x2 pin D4
- Arduino Uno R3 pin 6; Character LCD, 16x2 pin E
- Arduino Uno R3 pin 4; Character LCD, 16x2 pin RS
- Arduino Uno R3 pin 5V; Character LCD, 16x2 pin VDD; Character LCD, 16x2 pin A
- Ground: Arduino Uno R3 pin GND; Character LCD, 16x2 pin VSS; Character LCD, 16x2 pin V0; Character LCD, 16x2 pin RW; Character LCD, 16x2 pin K
Change it and keep it
Open it in the editor, change the circuit or the code, and keep your version in a free account.