lcd connected to arduino uno board

How to control an LCD Display – Arduino Tutorial

Our latest tutorial is how to control an LCD display with an Arduino board.  LCD displays are a great way to give use feedback for a device in human readable form. It’s much nicer to the eye to display text feedback than using LED’s to display feedback. When using more that one LED for display purposes, a label is require where as an LCD writes the information in text or graphical form which is much more efficient.

The most common LCD display used for electronics projects is the 16×2 alpha numeric display based on the Hitachi HD44780 controller. LCD modules that do not use the HD44780 controller may still be compatible.  The LCD display we use in this tutorial is the 1602A module which uses the ST7066U controller that is compatible with the HD44780 instruction set.

Further on we will look into the the 16×2 LCD and it’s functionality, then we will construct a project that connects the LCD module to an Arduino UNO which writes a message to the display.

 

You can watch a video on How to control an LCD Display

 


 

How a microcontroller controls the LCD Display

This particular LCD display uses a parallel interface to the microcontroller, while other displays can use the I2C protocol. We can use either 4 bit or 8 bit communications with the microcontroller, however, using 4 bit reduces the amount of I/O lines required by the LCD display by 5 bits (4 bits + RW) allowing us to only use a total of 6 I/O lines. Using less IO is important on smaller microcontroller chips as the number is limited. Using a 4 bit data bus is slower than using the 8 bit mode but for most purposes the difference will not be noted.

The pins required to communicate with the LCD display are the RS, RW, E plus 4 or 8 data lines. When using 4 bit mode, the RW pin is grounded.

There are 16 pins on this particular LCD display board and are layout as follows:

 

1 – VSS (Ground)

2 – Vdd (+5V)

3 – Vo (contrast adjustment 0-5V)

4 – RS

5 – RW (grounded in 4 bit mode)

6 – E (enable)

7 – D0

8 – D1

9 – D2

10 – D3

11 – D4

12 – D5

13 – D6

14 – D7

15 – A (+ 5V for backlight)

16 – K (Gnd for backlight)

 

Contrast Adjustment

The LCD contrast can be adjusted by varying the VO pin voltage between 0V and 5V. The voltage is varied by using a potentiometer or variable resistor that acts as a voltage divider.

 

Backlight

For LCD modules with a backlight, they can be powered up independently of the LCD’s main power supply VDD. You can directly power +5V to it or reduce the voltage to dim the brightness.

 

Character set

Along with the standard 0-9, a-z and A-Z characters there are many special characters. There is also allowance in the controller for 8 (5×8 pixel) custom characters.

 

Other Functions

The cursor can be visible, hidden or blinking also the Entire Display can be switched on or off.

 

Components Required to Control the LCD Display

  • Dupont wires
  • 16×2 LCD Display with HD44780 or compatible chipset
  • 10k Ohm variable resistor or potentiometer
  • Breadboard
  • Arduino Uno or compatible board

 

 

 

Breadboard Schematic that Show how the LCD Display and Arduion board are Connected

Source Code to Display Text on the LCD Display

The source code is very simple. It uses just the LiquidCrystal.h library. The microcontroller pins that are to be used are listed in in the second line of code: LiquidCrystal lcd(RS, E, D4, D5, D6, D7). The 16×2 LCD is selected and the initial cursor position as well as the text to be displayed on both LCD lines are set. Once the code is complete it can be uploaded to the microcontroller board.

 

I hope this tutorial was helpful to you.

Please check back again soon for more information about programming microcontrollers and basic electronics.