►Introduction

Keypads are a part of HMI or Human Machine Interface and play really important role in a small embedded system where human interaction or human input is needed. Martix keypads are well known for their simple architecture and ease of interfacing with any microcontroller. In this part of tutorial we will learn how to interface a 4x4 matrix keypad with AVR and 8051 microcontroller. Also we will see how to program then in Assembly and C.


►Constructing a Matrix Keypad

Constuction of a keypad is really simple. As per the outline shown in the figure below we have four rows and four columns. In between each overlapping row and column line there is a key.


4x4 matrix Keypad outline

So keeping this outline we can constuct a keypad using simple SPST Switches as shown below:


4x4 matrix Keypad schematic

Now our keypad is ready, all we have to do is connect the rows and columns to a port of microcontroller and program the controller to read the input.


►Scanning a Matrix Keypad

There are many methods depending on how you connect your keypad with your controller, but the basic logic is same. We make the coloums as i/p and we drive the rows making them o/p, this whole procedure of reading the keyboard is called scanning.


In order to detect which key is pressed from the matrix, we make row lines low one by one and read the coloums. Lets say we first make Row1 low, then read the columns. If any of the key in row1 is pressed will make the corrosponding column as low i.e if second key is pressed in Row1, then column2 will give low. So we come to know that key 2 of Row1 is pressed. This is how scanning is done.


So to scan the keypad completely, we need to make rows low one by one and read the columns. If any of the button is pressed in a row, it will take the corrosponding column to a low state which tells us that a key is pressed in that row. If button 1 of a row is pressed then Column 1 will become low, if button 2 then column2 and so on...


Now lets move on to the programming part of keypad in our next section.

◄ Back to Index  |  Connecting a Keypad ►

Conversation

Fri Dec 19 2014, 11:31 AM
1
-1'
Fri Dec 19 2014, 11:30 AM
1
1
ajay_bhargav
Fri Dec 12 2014, 04:38 AM
@Abdul BAsit, Post in forum please. We will help you.
Wed Dec 10 2014, 06:41 PM
Abdul BAsit
I am working on smoke detector using AT89S52 and dont know how its wors..kindly send me circuit diagram and code for its hardware & software implementation
Tue Dec 09 2014, 11:30 AM
Irinel
Please send me the content of that cd-rom (embedded c - michael j pont. Thank you.
Tue Dec 09 2014, 02:45 AM
kmyo
please give me the operation of 12v trickle charger
Sun Dec 07 2014, 07:50 AM
hidawi
we need the circuit diagrom of the remote control of iduction motor by android appliction
PsySc0rpi0n
Tue Dec 02 2014, 10:30 AM
I have no idea... I'm new to micro controllers
Tue Dec 02 2014, 08:35 AM
samarnath dev
how can usb key bord interfasing to dot matrx led moving, by asm51 ?
Tue Dec 02 2014, 08:32 AM
samarnath dev
how can usb key bord interfasing to 8051 by asm code?

Downloads

Comments

naimish324
Wed Dec 17 2014, 04:48 AM
sathish177
Tue Dec 16 2014, 06:43 PM
djnokey
Sat Dec 13 2014, 12:12 PM
sai9113
Tue Dec 09 2014, 07:23 AM
alexlomol
Fri Dec 05 2014, 12:06 AM
chandujonty
Thu Dec 04 2014, 10:11 AM
fantasy1214
Mon Dec 01 2014, 01:45 PM
vumbelino
Sat Nov 29 2014, 04:43 PM

Online

Guests: 54, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 37560
Newest member: naimish324
Forum Activity
sankalp_s Avatar
Posted By sankalp_s
Sat Dec 20 2014, 05:31 PM
For what you want,it is easier to not use interrup...
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Dec 19 2014, 09:58 PM
For what you want,it is easier to not use interrup...
sankalp_s Avatar
Posted By sankalp_s
Fri Dec 19 2014, 06:04 PM
This version works.Edit it to use either method. ...
muhibraza Avatar
Posted By muhibraza
Fri Dec 19 2014, 08:05 AM
software_developer Avatar
Posted By software_developer
Fri Dec 19 2014, 04:54 AM
Which files i have to use?Please give me .zip fold...
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Dec 19 2014, 12:21 AM
This version works.Edit it to use either method. ...
sankalp_s Avatar
Posted By sankalp_s
Thu Dec 18 2014, 08:40 PM
SIR THIS CODE IS NOT WORKING.. ORG 000H ; starting...
sankalp_s Avatar
Posted By sankalp_s
Thu Dec 18 2014, 08:36 PM
i've tried this code but faced a syntax error on l...
sankalp_s Avatar
Posted By sankalp_s
Thu Dec 18 2014, 08:32 PM
SIR THIS CODE IS NOT WORKING.. ORG 000H ; starting...
ajay_bhargav Avatar
Posted By ajay_bhargav
Thu Dec 18 2014, 04:24 AM
Code is all ok.. just change EXT0 to EX0... By mis...