Sunday, February 28, 2016

Connecting multiple LCD displays to an Arduino

The LCD Display

The LCD Display based on Hitachi HD (or equivalent) have been around for many years. They are a very popular way to display information on any microcontroller circuit.

They are available from many manufacturer and are in various display size. The usual size is 16x2 characters but you can find variants in 40x2 characters or 16x4 characters.

The display includes the full circuitry to drive the display and interface with the microcontroller.

Interfacing with the Arduino

 Interfacing with the Arduino is very straight forward and very well documented in

The schematic is quite simple:

We can limit the number of wires used on the Arduino by using a 4 bits interface instead of 8 bits and hardwiring the R/W pin to VSS since we don't need to read back information for the display.

This means that the interface is reduced to 4 data bits (DB4...DB7) and the 2 control wires: RS and E.
RS is used to select the register where the data shall be written (one register is used to display text and the other one is used to control the display behaviour) . The E wire is used to perform the actual data write operation.

To access the LCD display from the Arduino sketch we use an object of the LiquidCrystal class (for the standard Arduino library LiquidCrystal.h) by creating it with the correct pin assignation:

  lcd(12, 10, 5, 4, 3, 2);

Warning: When wiring the display, check carefully the manufacturer datasheet to find the correct pinout. Every manufacturer agrees that there are 14 pins to control the LCD + 2 pins to control the backlight but the exact pin assignation varies slightly from a manufacturer to another.

Multiple Displays

Now we want to connect one (or more) additional displays to the Arduino

As explained above the LCD display takes the data into account only when the E pin is activated. This means that you can connect all the displays signals in parallel on the Arduino digital outputs as long as you keep the E signals separated.

In the schematics below I have used digital output D10 to control E signal of LCD1  and output D11 to control E signal of LCD2

The Software

The Arduino sketch to control multiple displays is very similar to the one used to control one display.

You simply have to create one object of the LiquidCrystal class for each display. I have found that the easiest way to do it is to store them in array by using the following code:
LiquidCrystal lcd[2]={LiquidCrystal(12, 11, 5, 4, 3, 2), LiquidCrystal(12, 10, 5, 4, 3, 2)};

This allows to easily select on which display to print (or to send any command) as shown in the very simple "Hello World" example below.

warning, since arrays begin at index zero, the 2 LCD displays shall be numbered zero and on1 (instead of one and two).

This sketch prints "Hello World!" on 2 LCD displays
The circuit:
* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11 for LCD1 pin 10 for LCD 0
* LCD D4 pin to digital pin 5
* LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 3
* LCD D7 pin to digital pin 2
* LCD R/W pin to ground
* LCD VSS pin to ground
* LCD VCC pin to 5V
* 10K pot
* ends to +5V and ground
* wiper to LCD VO pin

// Directly based on the Arduino example LiquidCrystal HelloWorld
#include <LiquidCrystal.h>

LiquidCrystal lcd[2] = { LiquidCrystal(12, 11, 5, 4, 3, 2),LiquidCrystal(12, 10, 5, 4, 3, 2) };

void setup() {
// set up the LCD's number of columns and rows:
lcd[0].begin(16, 2);
lcd[1].begin(16, 2);
lcd[0].setCursor(0, 0);

lcd[1].setCursor(0, 0);

void loop() {

No comments:

Post a Comment