2010-09-20

Scanning algorithm for 3 x 4 Keypad Matrix

When a keypad is connected with a microprocessor, e.g 8051, a scanning algorithm is used to detect the pressed keys. See shown in [1]


Scanning 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
Reference: 
[1]http://www.dnatechindia.com/index.php/Tutorials/8051-Tutorial/Interfacing-Matrix-Keypad-to-8051.html

2 comments: