LCD Display Demo

This demo shows how to use LCD displays that are compatible with the Hitachi HD44780 driver using a 16 pin interface, similar to the one illustrated below. An Arduino Uno clone is used to drive the display.

Front and rear view of 4 row, 20 column LCD display

The demo does note show how to use displays with I²C interfaces.

The LCD has the following pins, reading from left to right as viewed with the screen facing up:

Pin name Description
VSS or GND Ground
VDD or VCC 5V input
VO Contrast adjustment. Voltage range is 0V to 5V.
RS Register select. Selects command register when low, data register when high.
RW Read / Write. Low to write to the register, high to read the register.
E Enable. Sends data to data pins when pulsed.
D0 Data pins.
There are both 8 bit and 4 bit data modes. In 4 bit mode D0 to D3 are not used.
The 4-bit mode is used in this demo.
A or LED+ Backlight LED anode. Most boards require that a voltage suitable for the LED is provided. Use a drop down resistor if connecting to 5V.
K or LED- Backlight LED cathode. Ground.

A breadboard was used to connect the Uno to the LCD display. The following images show the design and the circuit as built.

Breadboard circuit design with Uno and LCD displayBreadboard circuit design

Breadboard circuit as built with Uno and LCD displayBreadboard circuit as built

The breadboard design shows a 2 row, 16 column display while the circuit as built uses a 4 row, 20 row display.

In this example power from the LCD is supplied from the Uno to the breadboard 5V and ground rails. Connections are as follows:

LCD pin Connection
VSS or GND Breadboard ground rail.
VDD or VCC Breadboard 5V rail.
VO Wiper of 10k potentiometer. The potentiometer has its end terminals attached to the breadboard 5V and ground rails.
RS Uno pin 12.
RW Breadboard ground rail.
E Uno pin 11.
D0 Not connected.
D1 Not connected.
D2 Not connected.
D3 Not connected.
D4 Uno pin 5.
D5 Uno pin 4.
D6 Uno pin 3.
D7 Uno pin 2.
A or LED+ Breadboard 5V rail via 220Ω resistor.
K or LED- Breadboard ground rail.

The demo source code is available from the cahamo/demo-projects repository on GitHub. The relevant code will be found in the lcd-display--uno directory. All the C++ code is in src/main.cpp.

This demo is a PlatformIO project for use with Visual Studio Code. It can be modified for use with the Arduino IDE simply by copying the code from src/main.cpp into a new, blank Arduino API project and ensure that the LiquidCrystal library is installed.

Once the code is compiled and uploaded to the Uno you should see the text of the first two verses of Jabberwocky (poem by Lewis Carroll) begin to scroll up from the bottom of the display. After the poem is displayed then the screen is slowly filled with asterisks and finally the screen is flashed.

By default the code assumes the display is 4 rows by 20 columns, but it is easy to adjust the program to work with other display sizes. To do this simply change the values of the ROWS and COLUMNS defines. The code will then automatically adjust the length of the lines of text to fit the display width and the scrolling logic to fit the display height.

You can see the demo running in the following video.