Featured

MAX30100 Pulse Oximeter and Heart Beat Sensor

MAX30100 Pulse Oximeter and Heart Beat Sensor

MAX30100 Pulse Oximeter and Heart Beat SensorThis is a Pulse Oximeter and Heart rate Sensor module b..

Rs.2,300.00

AD8232 ECG Sensor Module

AD8232 ECG Sensor Module

AD8232 ECG Sensor ModuleECG also known as Electrocardiogram is a noninvasive medical procedure to me..

Rs.1,950.00

Interfacing Matrix Keypad to 8051



Before learning “Interfacing Matrix Keypad to Microcontroller” you should know how to interface a switch to microcontroller for which please click here.

 

Matrix_Keypad
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.

matrix_keypad1

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.

 

Written by Amol Shah

Amol Shah

Founder of DNA Technology an Electronic Engineer by choice. Started working on this website as an Hobby and now its a full time venture. Very passionate about Electronics and like to learn new stuff. Want to make DNA Technology one of the best Online Store for Electronics Components in India.
Follow Me Twitter | Facebook | Google Plus | Instagram