Please update your Flash Player to view content.

                  FOLLOW  US





 
 

Deprecated: Function split() is deprecated in /home/dnatechi/public_html/components/com_jcomments/jcomments.php on line 1245
Interfacing Matrix Keypad to 8051
Tutorial - 8051 Tutorial
Written by Amol Shah   

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.

 

 

Comments  

 
0 # Bilalo Sadiq 2011-11-10 21:52
hello....thanks a lot for this nice and clear presentation
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
Reply | Reply with quote | Quote
 
 
0 # amol shah 2011-11-10 22:39
the same algorithm can be used for 4x4 matrix....and for interfacing seven segment display check following link: dnatechindia.com/.../...
Reply | Reply with quote | Quote
 
 
0 # Phiny 2012-03-27 12:06
im doing my last year in Intelligent industrial systems and this articles helped me a lot with my projects we love your work thank u very much
Reply | Reply with quote | Quote
 

Add comment


Security code
Refresh

 

Featured Products

Rs250.00

Rs1 800.00

 

Random Products





Rs9.00



Rs150.00





Latest Video

Random Articles

Search Products

User Login






 
 
.
 TUTORIALS
.
  8051 Tutorial
 
  Power Supply
 
CODE LIBRARY
.

  8051 Assembly
 
  C Code Library

.
 PROJECTS
.
  Project List
 
  Synopsis and Abstract
 
DOWNLOADS
.

  Datasheets
 
  Download

.
 POPULAR
.
  About Us
 
  DNA Shop
 
  Totorial
 
  Code Library
 
  Download
 

.
 CONTACT US
.

Mr. Amol Shah

DNA Technology Nashik,

Maharashtra 422009 India

Phone : 0253-3023939

Mobile : 09225145135

Email : contact@dnatechindia.com