LCDs are alphanumeric (or graphical) displays. They are frequently used in microcontroller based applications. There are many devices in the market which come in different shapes and sizes.

Some LCDs have 40 or more character lengths with the capability to display several lines. Some other LCD displays can be programmed to display graphic images. Some modules offer color displays, while some others incorporate back lighting so that they can be viewed in dimly lit conditions. 
In terms of interfacing technique, we can group them in two categories:  Parallel LCDs and serial LCDs. 
Parallel LCDs like the popular Hitachi HD44780 series are connected to the microcontroller circuitry such that data is transferred to the LCD using more than one line and usually four data lines (4-bit mode) or eight data lines (8-bit mode) are used. 
Serial LCD is connected to a microcontroller using one data line only and data is transferred using the RS232 asynchronous data communications protocol. Serial LCDs are generally much easier to use, but they are more costly than the parallel ones. In this article we will discuss only the parallel LCDs, as they are cheaper and are used more commonly in microcontroller-based projects. Arduino provides built-in libraries for interfacing the HITACHI HD44780 controller.This module is monochrome and comes in different shapes and sizes usually with character lengths of 8, 16, 20, 24, 32, and 40 and 1, 2 or 4 lines. Each character consists of 5×8 or 5×11 dot matrix.

A 2x16 LCD Display

Figure 1: A 2×16 LCD Display

This LCD display device generally has 14 pins which are marked on the PCB with some models have 16 pins if the the device has a back-light built in.

Function Pin Number Name Logic State Description
Ground 1 Vss 0V
Power supply 2 Vdd +5V
Contrast 3 Vee 0V to +5V
Control of operation 4 RS 0 D0-D7 are interpreted as commands
1 D0-D7 are interpreted as data
5 R/W 0 Write data (from microcontroller to LCD)
1 Read data (from LCD to microcontroller)
6 E 0 Access to LCD disabled
1 Normal operation
From 1 to 0 data/ commands are sent to LCD
Data/ commands 7 D0 0/1 Bit 0 LSB
8 D1 0/1 Bit 1
9 D2 0/1 Bit 2
10 D3 0/1 Bit 3
11 D4 0/1 Bit 4
12 D5 0/1 Bit 5
12 D6 0/1 Bit 6
14 D7 0/1 Bit 7 MSB

Table 1: Pin descriptions

Table 1 above shows the pin configuration and pin functions of a typical 14-pin LCD. If back-light is needed and available, The LED – pin should be connected to ground and pin LED + should be connected to positive supply via a series current limiting resistor as shown in figure 3 below.

LCD Connection

Table 1 shows the description of each pin of the LCD display, a 10K variable resistor can be connected, the wiper to LCD pin 3 (Vee) to adjust the contrast the LCD. A 220 ohms series resistor is used for the LCD back light.

Figure 2: LCD on a Breadboard connected to Arduino Uno

Arduino LiquidCrystal Library

This library allows an Arduino board to control LiquidCrystal displays (LCDs) based on the Hitachi HD44780 (or a compatible) chipset, which is found on most text-based LCDs. The library works with in either 4- or 8-bit mode (i.e. using 4 or 8 data lines in addition to the rs, enable, and, optionally, the rw control lines).

Here is the description of few LiquidCrystal library, you can learn more from Arduino LiquidCrystal Library page

LiquidCrystal()
Description: This function is used to initialize the connections of LCDs. It creates a variable of type LiquidCrystal. You can specify to control the LCD either in 8-bit or 4-bit mode.
Syntax:

  • RS indicates the Arduino pin number to which LCD RS (Register Select) is connected.
  • EN indicates the Arduino pin number to which LCD EN (Enable) is connected.
  • RW indicates the Arduino pin number to which LCD RW (Read / Write) is connected. Since we usually write data to LCD and seldom read data from the LCD, we can connect this pin to ground instead of connecting it to Arduino.
  • D0 – D8 indicates Arduino pin numbers to which LCD data pins are connected.

Example:

begin()
Description: This function initializes the LCD and specifies the dimensions (width and height) of the display. begin() needs to be called before any other LCD library commands.
Syntax:

Example:

clear()
Description: This function clears the LCD display and sets the cursor to upper left corner.
Syntax:

home()
Description: This function sets the cursor to upper left corner.
Syntax:

write()
Description: Writes a character to LCD display.
Syntax:

print()
Description: This function prints text to the LCD.
Syntax:

setCursor()
Description: This function sets the position of the LCD cursor. That means the location in which the subsequent data is displayed on the screen. In this function we can specify in which column and row we want to display our data. Note that the numbering of columns and rows are starting from 0.
Syntax:

cursor()
Description: This function displays the cursor (an underscore) on the LCD display at a position in which next character will be written.
Syntax:

noCursor()
Description: This function hides the LCD cursor.
Syntax:

blink()
Description: This function displays blinking cursor on LCD display. This is useful in some cases where user input is required.
Syntax:

Example

Display the words “2×16 LCD Display” on first line of LCD and “studentcompanion on second line as shown in the circuit diagram on figure 3 below. The LCD is connected in 4-bits mode. RS and E pins are connected to Arduino pins 12 and 11 respectively. The RW pin is connected to ground and data pins D4 to D7 are connected to Arduino pins 5 to 2.

Figure 3: LCD Display connected to Arduino Uno Board

You can download the full project files (Arduino Sketch and Proteus Schematic design) below here.  All the files are zipped, you will need to unzip them (Download a free version of the Winzip utility to unzip files).  

Download: Arduino-LCD-Proteus

Download: LCD_Sketch