►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 ►
Forum Activity
ExperimenterUK Avatar
Posted By ExperimenterUK
Mon Jul 28 2014, 11:17 PM
Link the tx and rx pins on HC06, everything you se...
ExperimenterUK Avatar
Posted By ExperimenterUK
Mon Jul 28 2014, 11:13 PM
another chip is also same problem... i am confused...
pravin_35 Avatar
Posted By pravin_35
Mon Jul 28 2014, 01:33 PM
I suggest you to try with another chip of same and...
pravin_35 Avatar
Posted By pravin_35
Mon Jul 28 2014, 05:29 AM
I suggest you to try with another chip of same and...
ajay_bhargav Avatar
Posted By ajay_bhargav
Mon Jul 28 2014, 03:23 AM
I suggest you to try with another chip of same and...
pravin_35 Avatar
Posted By pravin_35
Mon Jul 28 2014, 03:11 AM
just now tried with Mplabx screen shotpravin_35Are...
ajay_bhargav Avatar
Posted By ajay_bhargav
Mon Jul 28 2014, 02:45 AM
just now tried with Mplabx screen shotpravin_35Are...
pravin_35 Avatar
Posted By pravin_35
Mon Jul 28 2014, 01:06 AM
If you uncheck program memory and EEPROM it means ...
ajay_bhargav Avatar
Posted By ajay_bhargav
Mon Jul 28 2014, 12:34 AM
If you uncheck program memory and EEPROM it means ...
ajay_bhargav Avatar
Posted By ajay_bhargav
Mon Jul 28 2014, 12:32 AM
HC-06 module is nothing but a serial connection ov...

Conversation

ajay_bhargav
Mon Jul 28 2014, 12:34 AM
@ Anshu Raj sorry we do not take such requests.
Sun Jul 27 2014, 12:23 AM
Anshu Raj
sir plz send the automatic collage alram bells in 2 hrs bells ring. For microcontroller programme plz sir
ajay_bhargav
Thu Jul 24 2014, 01:06 AM
@R.ABHISHEK where? I dont see it. is it in forum?
Wed Jul 23 2014, 05:49 AM
R.ABHISHEK
sir,pls message on microcontroller 8051 assambly language new program
Wed Jul 23 2014, 05:47 AM
R.ABHISHEK
sir,pls message on 8051 microcontroller assambly language program new quastions
ajay_bhargav
Tue Jul 22 2014, 09:18 AM
@Pragya Android application is taken from google play. Only Author has its source with him. Application is only used in this project.
Tue Jul 22 2014, 04:58 AM
Pragya
plz send me 8051 code and android code for android based device controller via Bluetooth .Here in this project I am using Hc-06 Bluetooth module
Thu Jul 10 2014, 09:57 AM
Caleb
plz someone mail me the source code for that project
Thu Jul 10 2014, 09:57 AM
Caleb
http://www.8051projects.net/download-d188-control-your-pc-tv-remote.html
ExperimenterUK
Tue Jul 08 2014, 03:25 PM
Post questions in the forum.. this area is for chat

Downloads

Comments

Abbasans786
Mon Jul 28 2014, 03:15 AM
Imran.pk
Fri Jul 25 2014, 07:50 PM
PavanKh
Fri Jul 25 2014, 12:56 AM
vinosentinal
Mon Jul 21 2014, 08:28 PM
niks_here
Sun Jul 20 2014, 05:38 PM
athiramsankar
Sun Jul 20 2014, 12:00 PM
salemalqahtani
Sun Jul 20 2014, 12:55 AM
nagarajan.electro
Sat Jul 19 2014, 12:49 AM

Online

Guests: 54, Members: 0 ...

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

Members: 37482
Newest member: Abbasans786