SparkFun will be closing early at 3:30 Friday 5/27 and remain closed Monday for Memorial Day (5/30). Orders placed after 2pm MT on Friday (5/27) will process and ship out on Tuesday (5/31).

LCD 16x2 Add-On

How it works

LCD stands for Liquid Crystal Display. These displays contain a grid of liquid crystal dots, or pixels held between layers of glass etched with transparent electrodes. Liquid crystal molecules are normally twisted, but straighten out when electricity is applied to them. This affects the way light passes through the dot, allowing it to appear either darkened or clear. A HD44780 controller chip built into the display (it's underneath the black blob on the back) receives commands from your Arduino, and turns the pixels on and off to form various letters, numbers and symbols. The controller datasheet has a diagram of all the characters stored in the chip. This display also has an LED for backlighting, which is powered through LCD pins 15 and 16.

Assembling the display

The kit comes with the display module, a strip of header pins, and a potentiometer to adjust the contrast of the display. You will need to solder the header pins to the display in order to plug it into your breadboard. Follow this link to our handy assembly guide, and come back here when you're done.

Connecting the display to your Arduino: hardware

This display uses a parallel interface, which can be either 4 bits or 8 bits wide. We'll use 4 bits, since it requires fewer wires. It will take a total of 8 wires to connect the display to your Arduino; four for data, two to load the data, and two for power and ground. You will also need to connect the supplied potentiometer to the display; this is necessary to set the contrast of the display for best visibility. See the following schematic and layout for details:

see http://www.sparkfun.com/tutorial/AIK/LCDD-01-SPAR-guide.pdf



(Click here for a full-sized cutout you can place over your breadboard)

Connecting the display to your Arduino: software

Normally you would need to read the HD44780 controller chip's extensive datasheet to determine how to control this display. Fortunately, the Arduino comes with a built-in library called LiquidCrystal which does all the hard work for you. (A library is a prebuilt collection of software functions that you can easily include in your code).

Open the Arduino IDE, and load the example program: File > Examples > LiquidCrystal > HelloWorld. Upload it to your board, and "hello, world!" should appear on the display. If no message appears, the contrast may need to be adjusted. To do this, turn the potentiometer until "hello, world!" is at maximum contrast. If you still don't see anything, double-check your wiring.

If you do see "hello, world!", congratulations! Take a look at the example sketch, and try modifying it to display "hello, your name!" or any other text you'd like. Also take a look at the other example LiquidCrystal sketches, and the documentation on the Arduino.cc website to see how to write sketches to take advantage of the display.

The LiquidCrystal library

Here's a few of the LiquidCrystal library commands to get you started. For the full list, see: http://arduino.cc/en/Reference/LiquidCrystal.

#include ;
// Tell the Arduino you want to use the LCD library

LiquidCrystal lcd(12,11,5,4,3,2)
// Create a new LiquidCrystal object named lcd
// using the listed pins for a 4 bit data bus (as in the above schematic)

// Initializes the library for a 16 x 2 display

// Clears the display and moves the cursor to upper left corner

// Just move the cursor to the upper left corner

lcd.setCursor(col, row);
// moves the cursor to column col and row row

// prints a string ("hello, world!") or numerical data (data, BASE) to the display

More information

LCD Add-On for SIK (DEV-10054) product page

PDF guide for DEV-10054

LiquidCrystal library reference at Arduino.cc

LCD datasheet (basic)

LCD datasheet (extended)

HD44780 datasheet

Comments 3 comments

  • I just downloaded the latest IDE and it doesn’t have the driver code (no LiquidCrystal directory under “examples”). Is this available separately (possibly on GitHub)?

  • Good instructions. After I followed the instructions, both assembly and getting the Hello World example from the library worked first time. Be aware you may have to adjust the contrast (pot clockwise to increase backlight) if you don’t see any output on the LCD. I had a problem because I accidentally put the 16 pin header in wrong and had to unsolder it. If one looks at the pictures and thinks they should not make this mistake. About the comment in this thread about the library - I found it listed under Sketch - Import and imported it no problem.