Built-in project · Arduino Uno R3

Twenty by four on an Arduino Uno

Two 20x4 character LCDs, one on six wires and one on its I2C backpack. A long line runs off row 0 and carries on in row 2. The whole build, an Arduino Uno and 2 more parts, 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.

IntermediateRuns in your browser. Free, and no account needed.

Twenty by four · Arduino Uno R3live0.000 s 0.00x
Click to open it in the editor
The circuit itself, running here on the simulator. Press what can be pressed; click anything else to open it in the editor.

The code

The firmware exactly as the editor opens it. Change a line there and press Run: it compiles in the browser.

sketch.ino · Arduino Uno R3
// Twenty by four: two 20x4 character LCDs, one on six wires and one on two.
//
//   bare 20x4   RS -> 2   E -> 3   D4..D7 -> 4, 5, 6, 7
//               VSS, V0, RW -> GND    VDD -> 5 V
//   I2C 20x4    SDA -> A4   SCL -> A5   VCC -> 5 V   GND -> GND
//
// A 20x4 is the same HD44780 controller as a 16x2, and the controller only has
// two lines of memory, forty characters each. The panel shows each line twice
// over: row 0 is the first twenty characters of line 1 and row 2 the next
// twenty, rows 1 and 3 the same of line 2. So the rows start at 0x00, 0x40,
// 0x14 and 0x54, and setCursor() knows that.
//
// The bare panel shows what happens without it: one long print runs off the
// end of row 0 and carries on in row 2, not row 1. The I2C panel counts, with
// each row placed by setCursor().

#include "mokxi_lcd1602.h"
#include "mokxi_lcd1602_i2c.h"

Lcd1602 bare(2, 3, 4, 5, 6, 7);
Lcd1602I2c backpack(A5, A4);

void setup() {
  bare.begin();
  // Forty characters in one go: the second twenty land in row 2.
  bare.print("Row 0 runs off here ");
  bare.print("and on into row 2...");
  bare.setCursor(0, 1);
  bare.print("Row 1 is line 2");

  backpack.begin();
  backpack.setCursor(0, 0);
  backpack.print("Twenty by four");
  backpack.setCursor(0, 1);
  backpack.print("rows at 00 40 14 54");
  backpack.setCursor(0, 2);
  backpack.print("seconds:");
}

void loop() {
  backpack.setCursor(9, 2);
  backpack.print((long)(millis() / 1000));
  backpack.setCursor(0, 3);
  backpack.print("row 3 is 0x54");
  delay(250);
}

Parts list

4 parts, plus the jumper wires. Every one is in the editor's parts bin.

How it is wired

10 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 7; Character LCD, 20x4 pin D7
  • Arduino Uno R3 pin 6; Character LCD, 20x4 pin D6
  • Arduino Uno R3 pin 5; Character LCD, 20x4 pin D5
  • Arduino Uno R3 pin 4; Character LCD, 20x4 pin D4
  • Arduino Uno R3 pin 3; Character LCD, 20x4 pin E
  • Arduino Uno R3 pin 2; Character LCD, 20x4 pin RS
  • Arduino Uno R3 pin 5V; Character LCD, 20x4 pin VDD; Character LCD, 20x4, with I2C backpack pin VCC
  • Ground: Arduino Uno R3 pin GND; Character LCD, 20x4 pin VSS; Character LCD, 20x4 pin V0; Character LCD, 20x4 pin RW; Character LCD, 20x4, with I2C backpack pin GND
  • Arduino Uno R3 pin A4; Character LCD, 20x4, with I2C backpack pin SDA
  • Arduino Uno R3 pin A5; Character LCD, 20x4, with I2C backpack pin SCL

Change it and keep it

Open it in the editor, change the circuit or the code, and keep your version in a free account.