►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

Mon May 04 2015, 09:06 AM
wasim
hi all , im doing my attendance project using EM-18 rfid ,my project issue is when the card is swiped its not getting read , plz help me
Sat May 02 2015, 04:30 AM
sharmi
hi am electronic student am doing project in vehicle monitoring system with arm processor using can protocol.i need proteus simulation result output using can and arm for displaying temperature ,gas and ldr sensor value
ExperimenterUK
Fri May 01 2015, 09:24 PM
months ! is this a very big track or a very slow kart ?
Fri May 01 2015, 06:40 AM
shaygan
Hey I am s mechanical eng student and I would like to make a countdown clock for my go-kart team but we need more digits , like MM,WW, DD, HH , mm , ss , ms (month , week , day , hour , minute , sec , milli sec) .. can anybody help and tell me to how make such thing in big scale ?
ExperimenterUK
Mon Apr 27 2015, 08:14 PM
@Janvier This project is in assembly. It is unlikely anyone has a 'c' code
Mon Apr 27 2015, 04:47 PM
Janvier
hello! can u help me to find c code for a project called " automatic light controller with visitor counter". Best regards.
ExperimenterUK
Mon Apr 27 2015, 05:27 AM
@mostfa.. it's a browser thing. Check your settings/try another browser.
Sat Apr 25 2015, 06:16 AM
rohan_verma
sir this circuit is tested?can i use it directly on developing PCB
Sat Apr 25 2015, 06:13 AM
rohan_verma
MSCOMM32.ocx cannot be copied in the systems folder even with administration rights.
Fri Apr 24 2015, 01:58 AM
mostfa
please fix the LCD Interfacing Tutorial as all pictures is gone

Downloads

Comments

manmanan120
Tue May 05 2015, 01:34 PM
Santhoshkumar458
Mon May 04 2015, 11:19 AM
israelo
Sun May 03 2015, 11:57 AM
djsamfisher
Fri May 01 2015, 07:15 AM
0pus0ne
Wed Apr 29 2015, 11:10 PM
ingsilor
Tue Apr 28 2015, 01:13 PM
Seven
Thu Apr 23 2015, 12:02 AM
killbillpandey
Wed Apr 22 2015, 09:07 PM

Online

Guests: 41, Members: 0 ...

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

Members: 37635
Newest member: manmanan120
Forum Activity
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue May 05 2015, 05:58 PM
What if we took ceramic capacitor of higher values...
ankitbajaj01 Avatar
Posted By ankitbajaj01
Mon May 04 2015, 05:02 PM
@Electrolytic Capacitor...Putting 220uF cap at 14V...
ankitbajaj01 Avatar
Posted By ankitbajaj01
Mon May 04 2015, 04:58 PM
Hello ExperimenterUK...@Ceramic CapacitorWhat if w...
ElectronicManiac Avatar
Posted By ElectronicManiac
Mon May 04 2015, 04:13 PM
I tried making a proteus file but it is not simula...
ElectronicManiac Avatar
Posted By ElectronicManiac
Mon May 04 2015, 04:11 PM
I tried making a proteus file but it is not simula...
ExperimenterUK Avatar
Posted By ExperimenterUK
Sun May 03 2015, 06:12 PM
How the value of this capacitor helps? Does smalle...
ankitbajaj01 Avatar
Posted By ankitbajaj01
Sun May 03 2015, 04:34 PM
Hello ExperimenterUK...Attaching the existing powe...
ExperimenterUK Avatar
Posted By ExperimenterUK
Thu Apr 30 2015, 10:03 PM
But Let me know that if I place 2200uF cap instead...
ankitbajaj01 Avatar
Posted By ankitbajaj01
Thu Apr 30 2015, 05:51 PM
Hello ExperimenterUK...I will be showing you the p...
ExperimenterUK Avatar
Posted By ExperimenterUK
Wed Apr 29 2015, 08:33 PM
Hello ExperimenterUK...My confidence gets boost up...