|
Before learning “Interfacing Matrix Keypad to Microcontroller” you should know how to interface a switch to microcontroller for which please click here.
|
 |
| Matrix Keypad |
|
|
As you have seen in the article for interfacing switches to microcontroller normally the port pin is high but when a switch is pressed the controller pin gets a Low signal and we come to know that a switch has been pressed. One end of switch is connected to the port pin whereas the other end is connected to the Ground.
|
|
|
|
In case of matrix Keypad both the ends of switches are connected to the port Pin. Over here we have considered a 4x3 matrix keypad i.e. four rows and three columns. So in all twelve switches have been interfaced using just seven lines.
|
|
The adjoining figure shows the diagram of a matrix keypad and how it is interfaced with the controller.
|
|
As you can see no pin is connected to ground, over here the controller pin itself provides the ground. We pull one of the Column Pins low & check the row pins if any of the Pin is low then we come to know which switch is pressed.
|
|
Suppose we make column 1 pin low and while checking the rows we get Row 3 is low then we come to know switch 7 has been pressed.
|
|

|
| Interfacing Matrix Keypad to 8051 |
|
|
|
|
ALGORITHM
|
|
|
|
1. Start.
|
|
|
2. Make All Pins High.
|
|
|
3. Make Column 1 pin low.
|
|
|
4. Check if Row 1 is low, if yes then Switch 1 has been pressed.
|
|
|
5. Check if Row 2 is low, if yes then Switch 4 has been pressed.
|
|
|
6. Check if row 3 is low if yes then Switch 7 has been pressed.
|
|
|
7. Check if row 4 is low if yes then Switch 10 has been pressed.
|
|
|
8. Make Column 1 Pin high & Column 2 Pin Low.
|
|
|
9. Check if Row 1 is low, if yes then Switch 2 has been pressed.
|
|
|
10. Check if Row 2 is low, if yes then Switch 5 has been pressed.
|
|
|
11. Check if row 3 is low if yes then Switch 8 has been pressed.
|
|
|
12. Check if row 4 is low if yes then Switch 11 has been pressed.
|
|
|
13. Make Column 2 Pin high & Column 3 Pin Low.
|
|
|
14. Check if Row 1 is low, if yes then Switch 3 has been pressed.
|
|
|
15. Check if Row 2 is low, if yes then Switch 6 has been pressed.
|
|
|
16. Check if row 3 is low if yes then Switch 9 has been pressed.
|
|
|
17. Check if row 4 is low if yes then Switch 12 has been pressed.
|
|
|
18. Make column 3 pin high.
|
|
|
19. Stop.
|
|
|
Please make sure at any time only one column Pin should remain Low.
|
|
|
For the complete working code in Assembly please check the code library or click here.
|
|
Comments
now i want to know how cani display data using 4x4 kypad on 4 seven segmentd
that is if i pressed on first attempt 1 display would be xxx1
on second attemp i pressed (Suppose 4) ) xx14
on 3rd attempt if i presed suppose 7 x147
and on 4th attemp i presses supppose 8 1478
how can i do this using C in 89c51
please helo me
RSS feed for comments to this post