Interfacing LCD and Keypad are one of the important interfacing concepts of PIC microcontroller since both the input and output element can form a complete embedded system design. This tutorial is about teaching you how to get input input values from keypad by polling method and display the input into a 16×2 LCD.
This type of LCD is widely used to display the status of the system and to display the obtain output. This LCD consists of 16 columns and 2 rows, therefore named as 16×2 LCD. Usually a LCD consists of two built in registers known as Data and Command register. Command reg is meant for giving commands such as blink on, cursor on/off etc while Data reg is to display the input character.
You have to follow these steps to write a command or data into the LCD.
- Place the Data/Command in the pins D0-D7 of the LCD.
- If you are intended to write command you gotta make the RS(register select) pin of the LCD low, that is RS=0
- Whereas for writing data you have to make this RS high, that is RS=1
- Then the EN of the LCD must undergo a high to low logic transition with some delay in between them, that is EN=1 to EN=0 with specific delay.
- The R/W pin should remain in the Logic 0.
Usually LCD’s have some preassigned commands that would do specific tasks in functioning of the LCD. The command table of a 16×2 LCD is given below.
|Command Table for 16×2 LCD
Still not clear about the working of LCD? I suggest you to go through this Tutorial on LCD interface
We have used a 4×3 keypad which means it has four rows and three columns in it. The keypad was scanned for any key inputs and this was done by means of a method called polling. The scanning takes place by keeping a specific Row low at a time and read the status of the column pins as input at that instant. This chain goes on through all the rows and by this way input is read by Microcontroller.
Read how to constuct keypad and how the scanning works in this Tutorial of Keypad Interface and scanning.
Rear More: Interfacing LCD and Keypad with PIC16F877A Microcontroller