Interfacing LCD with 8051

LCD Interface Feature
LCD Interface Feature

Introduction to Interfacing LCD with 8051:

Interfacing LCD with 8051, LCD as it name suggests is a Liquid Crystal Display Module. A display is basically used to communicate with the user or operator. A display is a real time indicating device which can display various information like running process, or anything else a programmer would like user to know about.

8051 series micro-controller were invented decades backs, in times when personal computers were just a theory so it has some limitations. Limitation we face with displays is we can interface only 16×2 LCD with micro-controller 8051.

In order to interface any device first we need to have basic knowledge of the device its pin configuration and working. So we will first discuss and learn about working of LCD.

LCD pin out
LCD pin out

Major Pins of LCD are:

  1.  Register Select (RS)
  2. Read/Write (RW)
  3. Enable(E)
  4. DB0-DB7
  5. Vss
  6. Vcc
  7. Vee
  8. LED(+/-)

Register Select(RS):
In every device there are two operations mainly command and data, like wise in LCD we have two register Command Register and Data Register. To give various commands like initialization, operation mode, clear LCD, go to next line and many more are sent to LCD in command mode. And various data to be displayed are given in data mode. In order to select command mode.
RS=0 Command mode of LCD is selected.
RS=1 Data Register is selected.

Read/Write Pin (R/W):
Read/Write pin is used to read data from LCD or write data to LCD. Depending upon logic send to this pin, Read or Write mode of LCD is enabled.
R/W= 0 Writes data to LCD.
R/W=1 Read data from LCD.

Vss is connected to ground pin of the power supply. Vcc is positive supply, in normal practice it is connected to +5V. VEE is contrast pin of LCD, for maximum contrast it should be connected to ground. Usually we connect it to ground.

Enable Pin(E):
Enable pin acts similar to a trigger for LCD. A high to low pulse should be given to Enable pin before sending data to LCD. A low to high pulse indicates that data is to be written on LCD and LCD gets ready for same.

Data Bits of LCD (DB0-DB7):
These pins are used to send any data which is to be displayed on LCD. Just like numbers or any characters, all the data is transmitted to LCD using these pins.

Backlight pins of LCD(+/-):
Mostly every LCD module contains of built in backlight. In order to activate or turn on the backlight of LCD, LED+ should be connected to +5V and LED- should be connected to ground.

So in this project we will be interfacing 16×2 LCD with 8051.
It can be done in 2 modes:
1. 8 bit mode
2. 4 bit mode

8 bit mode of LCD Interfacing LCD with 8051:

In 8 bit mode, LCD uses all the data pins DB0-DB7 to transmit data to LCD and uses RS RW and E for control of LCD. So in all 11 pins will be required by LCD for its operation and communication with micro-controller.We will understand working of LCD in 8 bit mode in a separate article completely dedicated to interfacing LCD in 8 bit mode.

4 bit or nibble mode of LCD Interfacing LCD with 8051:

In this article we will focus on interfacing LCD is 4 bit mode or nibble mode. Nibble rightly means 1/2 byte or 4 bits so in this mode LCD data which is in bytes is divided into nibbles.

A byte has 2 nibbles, so in 4 bit mode only 4 pins of LCD are used for data and 3 pins for control. So in all only 7 pins are enough to control and transmit data to LCD which can be done using a single port. This approach is very much beneficial in projects where there are many peripherals to be interfaced with micro-controller.

Important Connections in Nibble mode/ 4 bit mode:

  1. RS – To select  register
  2. RW – To select operation mode
  3. E – To Enable LCD
  4. DB4 – DB7 : Data inputs for LCD

Circuit diagram Interfacing LCD with 8051

LCD Interface
LCD Interface

Above figure illustrates circuit diagram for LCD interfacing with 8051. Following connections are important for this interface:

  1. P2.0 – Connected to RS pin of LCD
  2. P2.1 – Connected to RW pin of LCD
  3. P2.2 – Connected to E pin of LCD
  4. P2.3 – Open or NC
  5. P2.4 – Connected to DB4 pin of LCD
  6. P2.5 – Connected to DB5 pin of LCD
  7. P2.6 – Connected to DB6 pin of LCD
  8. P2.7 – Connected to DB7 pin of LCD
Program Files:

/*Title: LCD Test Code 


#include<reg51f.h> // Use this header file while using P89V51RD2 Devices     
// While using AT89C51, AT89S51/52 and other 8051 Devices use reg51.h or reg52.h
void main(void){
LCD_puts("  TECHLABS ");
LCD_puts(" ~_^");

Header Files or Custom Library:


Download both the files and copy them in the same folder where your C source file is store, to compile and generate hex or burnable file.

See more:

Electronic Voting Machine using 8051

Temperature Controller using 8051

Password lock using 8051



Please enter your comment!
Please enter your name here