We all are familiar with the LCDs (Liquid Crystal Display) that used to display the contents using the combination of characters. 16×2 LCD have 16 columns and 2 rows.




It mean a total number of 32 characters can be display on LCD.

16x2 lcd

As in this picture there are 14 pins. Now discuss the function of all pins and how to use them.

Pin 1 (VSS) :   VSS pin should be connected to ground (GND). It is the ground of LCD light.

Pin 2 (VDD):   VDD pin should be connected to +5V. it is the positive terminal of LCD light.

Pin 3 (VEE) :   VEE should be connected to the variable resistor to set the contrast of LCD by varying the resistance.

Pin 4 (RS) :   RS stands for register select. There are two registers in LCD. One is used to write the commands on LCD and other is used to write data on LCD. Commands are not displayed on LCD they just act. E.g Command to clear LCD, command to go to next line, command to go previous character, etc. Data is displayed on LCD e.g any character that you want to display. To write command we make RS pin LOW and to write data we make RS pin HIGH.

Pin 5 (RW) :   Read/Write pin is used to choose whether we are going to write on LCD of read from LCD.  To select write on LCD we have make this pin LOW otherwise HIGH.

Pin 6 (E)   :   Enable pin is used to implement the command/data on LCD. When we send low to high and high to low pulse to the LCD the command/ data that you are send to the data pins will be implemented.

Pin 7(D0-D7):   These 8 pins are used to get 8-bit data from the controller. It could be command or data

See the circuit diagram of the LCD to be connected to the microcontroller.

8051 lcd 16x2

Commands Table of LCD is shown below.

lcd 16x 2

Now let’s make a code that we connect two button with microcontroller. When button 1 is pressed LCD will display “Button One” and for button 2 LCD will display “Button Two”

First of all, we need to connect initialize LCD by sending the commands to the registers of LCD to tell that LCD is 16×2, clear the previous characters if any garbage, LCD light turn on, turn on cursor, set position of cursor at beginning.

See in the code.

lcd 16x 2 code

code for lcd 16x2 8051

Check the complete circuit below:

8051 lcd

Thanks

Hafiz Abdul Haseeb Tariq

This article was prepared for you by Hafiz Abdul Haseeb Tariq from FAST-National University of Computer and Emerging Sciences-Pakistan. He’s an Electronics & Embedded system engineer and has practical experience in circuit designing, networking, assembling, PCB making, 8051 & Arduino programming.




You can check out his previous article in the below link:

https://www.electronicsrepairfaq.com/working-of-keypad-and-its-interfacing-with-8051-microcontroller

About

Jestine Yong works as an Electronics Repair Lecturer in Kuala Lumpur Malaysia and his training website is http://www.NoahtechElectronicsTraining.com. You can check out his repair blog at http://www.JestineYong.com

3 comments on “Working of 16×2 LCD and its interfacing with 8051 Microcontroller

  1. Mohammed Aly says:

    thank you very much eng. Hafiz Abdul Haseeb for the useful info.

  2. Parasuraman says:

    Very good informative article!

  3. Mark Tembo says:

    I like this staff!
    Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.