Keypad Interfacing with Pic Microcontroller and Mikor C
In this tutorial I am show how to interface keypad with PIC16F877A microcontroller. In this project I am use 3x4 matrix keypad. You can watch this video or read the written tutorial below.
Keypad is set of button. It contain digits,symbols&alphabetical letters. It can be (4x4),(4x3) & (3x2). 4x3 it means 3 column and 4 row. Matrix keypads are commonly used in calculator , digital scale, security systems ,electronic device etc. Matrix keypad is array of push switch. Push button switch leg are connected to columns and rows. 4x4 matrix keypad contain (4*4)=16 push button switch. If we are use 3x4 matrix there are (3*4)=12 push button switch. 4x4 matrix keypad has (4+4)=8 pin connection and 3x4 matrix keypad (3+4)=7 pin connection.
MATRIX KEYPAD
Before I interface the keypad with PIC16F877A microcontroller , frist we need to understand how to working matrix keypad.Keypad is set of button. It contain digits,symbols&alphabetical letters. It can be (4x4),(4x3) & (3x2). 4x3 it means 3 column and 4 row. Matrix keypads are commonly used in calculator , digital scale, security systems ,electronic device etc. Matrix keypad is array of push switch. Push button switch leg are connected to columns and rows. 4x4 matrix keypad contain (4*4)=16 push button switch. If we are use 3x4 matrix there are (3*4)=12 push button switch. 4x4 matrix keypad has (4+4)=8 pin connection and 3x4 matrix keypad (3+4)=7 pin connection.
4X4 MATRIX KEYPAD STRUCTURE
When press the any key than any column & row are connected each other at a time. Than current flowing column to row.
3x4 matrix keypad |
CIRCUIT DIAGRAM OF KEYPAD INTERFACING
3x4 matrix keypad and Lm16x2 Lcd display |
PROJECT ANALISIS
In this project keypad are connected PORTC. This keypad has 7 terminal and each terminal are connected. 3x4 mtrix keypad terminal are 1,2,3,A,B,C & D. 1,2 & 3 is row and A,B,C & D is column. Normaly row is active high(1) at a time and column is active low(0).
While press the any key from keypad the row is active high(1). Than microcontroller read the value.
While press the any key from keypad the row is active high(1). Than microcontroller read the value.
CASE 1 :
If RC2 active high(1) and press 1 than RC4 reached active high(1). Lcd display show digit first row and first column '1'.
CASE 2 :
If RC1 active high(1) and press 2 than RC4 reached active high(1). Lcd display show digit '2'.
CASE 3 :
If RC0 active high(1) and press 3 than RC4 reached active high(1). Lcd display show the digit '3'.CASE 4 :
If RC2 active high(1) and press 4 than RC5 reached active high(1). Lcd display show the digit '4'.CASE 5 :
If RC1 active high(1) and press 5 than RC5 reached active high(1). Lcd display show the digit '5'.CASE 6 :
If RC0 active high(1) and press 6 than RC5 reached active high(1). Lcd display show the digit '6'.CASE 7 :
If RC2 active high(1) and press 7 than RC6 reached active high(1). Lcd display show the digit '7'.CASE 8 :
If RC1 active high(1) and press 8 than RC6 reached active high(1). Lcd display show the digit '8'.CASE 9 :
If RC0 active high(1) and press 9 than RC6 reached active high(1). Lcd display show the digit '9'.CASE 10 :
If RC2 active high(1) and press * than RC7 reached active high(1). Lcd display cursor position is change. Cursor shift first row and first column of the Lcd display.CASE 11 :
If RC1 active high(1) and press 0 than RC7 reached active high(1). Lcd display show the digit '0'.CASE 12 :
If RC0 active high(1) and press # than RC7 reached active high(1). Lcd display cursor position is change. Cursor shift second row and first column of the Lcd displayLCD INTERFACING
In this project I am use LM16x02 LCD display. If you don't know how to interface Lcd display with microcontroller than click here for more details.
Mikor C code:
DOWNLOAD
You can download mikro C and protiues file. Click the download.
download |
This a good project
ReplyDelete