Image may be NSFW. Clik here to view. ![]() |
Design of LCD and Keypad Interface to PIC Mircocontroller |
Interfacing of 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 16x2 LCD.
16x2 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 16x2 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 16x2 LCD is given below.
Image may be NSFW. Clik here to view. ![]() |
Command Table for 16x2 LCD |
Still not clear about the working of LCD? I suggest you to go through this Tutorial on LCD interface
4x3 Keypad:
We have used a 4x3 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.
CODE:
The below code was built by using CCS C Compiler for PIC Microcontrollers.
|
The code comprises of Two subroutines - "lcd_msg()" is for writing data/command to the LCD where keypad() is to scan the keys of the keypad. In the "lcd_msg()" function the command/data value is directly passed to the function while calling by means of "char b" and RS value by using "int c" , 0 implies for command and 1 for data.
Was this tutorial helpful? Share this with others through social sites and don't forget to follow us there for more of these PIC microcontroller tutorials. Enjoy Coding.
Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.![]()
Image may be NSFW.Clik here to view.
Clik here to view.
Clik here to view.
Clik here to view.
Clik here to view.
Clik here to view.