Skip to content

LCD display

There are many types of display that can be used with an Arduino, but one of the most common is the 1602A 16 x 2 LCD screen.

16x2 LCD display (16 pin) Electrosome

There are several variations of the LCD display, and these notes refer to the type with 16 pins one the top edge as shown in the image above. Numbered 1 - 16 from left to right, the pin assignments are:

Pin Abbreviation Function
1 VSS Ground connection
2 VDD Power (+5V)
3 V0 Contrast
4 RS Register select
5 RW Read/write
6 E Enable
7 D0 Data pin 0
8 D1 Data pin 1
9 D2 Data pin 2
10 D3 Data pin 3
11 D4 Data pin 4
12 D5 Data pin 5
13 D6 Data pin 6
14 D7 Data pin 7
15 A Backlight power (+5V)
16 K Backlight ground

The layout below shows how to drive the LCD display directly from an Arduino Uno. Instructions can also be found on the Arduino web site

Connecting an LCD display using a shift register

Direct connection takes up a large number of digital pins. One method for reducing the footprint is to use a serial-to-parallel shift register. Writing the code to do this from scratch is quite difficult, and there are many libraries available on the Internet which have been implemented in slightly different ways. The instructions below take you through a relatively reliable method.

The first issue is that you need to update the built-in LiquidCrystal library:

  1. Find the location of the Arduino libraries on your computer. This will be different depending on your operating system.
  2. Rename the existing LiquidCrystal library folder (for example, to LiquidCrystal_old), and create a new empty folder.
  3. Download a zip file of the updated library from the Arduino web site The version of your IDE is probably greater than 1, so you should download the one called LiquidCrystal_1.zip
  4. Unzip the file and copy the contents into your new library folder

The new library should now be picked up automatically by the IDE when you include the line #include <LiquidCrystal.h>

The second challenge is getting the hardware connections right:

The final piece of the puzzle is the Arduino code. Again, the example on the Arduino web site is almost correct, but the version shown below should work with the display model and connections shown here.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
#include &lt;LiquidCrystal.h&gt;

// initialize the library with the number of the latch pin of the 74HC595)
LiquidCrystal lcd(10);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis()/1000);
}