►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

Wed Jul 01 2015, 05:14 PM
ShubhamBansal1996
i am making a project of connecting 4 8051's using a can bus for which i am using mcp2515 and mcp2551.but before making it i want to ensure it works by simulating it on proteus though the two ic's mentioned above dont seem to have models in proteus so is there anyone who can help me with that
ExperimenterUK
Tue Jun 30 2015, 05:24 PM
@sachinmm The 8051 timer can't do 1 second. It can do 50ms so count 20 times
sachinmm
Sat Jun 27 2015, 05:01 AM
how calculate 1 second delay in 8051 by using timer and what value should be store in TH0 & TLO register??
sachinmm
Fri Jun 26 2015, 08:25 AM
hello sir plz tell me how to know the 74HC165 parallel in serial out ic is fauty or not?
Wed Jun 24 2015, 08:24 AM
ben mutuku
How can one use XOR gate to ensure the first output is '1' and the next is '0'?
ExperimenterUK
Wed Jun 17 2015, 01:37 AM
@baz..try adding a hash and a semi colon
Sun Jun 14 2015, 06:31 AM
baz
@ExperimenterUK no..i dont do that i just type message example.. Hello my name is baz and then i click send message,
ExperimenterUK
Sun Jun 14 2015, 01:55 AM
@baz..did you end your message with a hash and a semi colon
Sat Jun 13 2015, 06:48 PM
asif Jamadar
I want the program for v/f control technique of 3 phase induction motor
Sat Jun 13 2015, 07:06 AM
baz
@ExperimenterUK okay thank you...but now I already complete and my dot matrix already light up but when i send message from pc to my hardware project it doesnt show any message on my dot matrix..its only blinking when i click send message....I really dont know whats the problem...I had follow all the steps...schematic and use the coding that have been provided..is it because firstly i had wrong burn the coding in AT24C16?? Is that effect ????

Downloads

Comments

Nals99
Fri Jul 03 2015, 08:33 AM
Mc_Comet32
Thu Jun 25 2015, 11:42 AM
yashaswi
Thu Jun 25 2015, 05:56 AM
Riki-cc
Tue Jun 23 2015, 10:48 AM
PadRlp
Thu Jun 18 2015, 02:11 PM
start
Thu Jun 18 2015, 01:30 PM
sheilabajos
Tue Jun 09 2015, 03:35 PM
martintan
Tue Jun 09 2015, 12:08 AM

Online

Guests: 29, Members: 0 ...

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

Members: 37672
Newest member: Nals99
Forum Activity
Nals99 Avatar
Posted By Nals99
Fri Jul 03 2015, 09:34 AM
Here you have an example using timer 0: void delay...
Nals99 Avatar
Posted By Nals99
Fri Jul 03 2015, 08:52 AM
Hi guys...I'm having some problems to transmit dat...
Karan123 Avatar
Posted By Karan123
Thu Jul 02 2015, 09:12 AM
@ajay_bhargav i will not prefer costly ic because ...
prajwalsnh Avatar
Posted By prajwalsnh
Wed Jul 01 2015, 05:21 AM
@ExperimenterUKThanks a lot for correcting my misc...
prajwalsnh Avatar
Posted By prajwalsnh
Wed Jul 01 2015, 05:17 AM
@ExperimenterUK Thank you for your simple and usef...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Jun 30 2015, 05:45 PM
The 8051 timer can't do 1 second. It can do 50ms, ...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Jun 30 2015, 05:38 PM
Debugging is the process of finding out why your ...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Jun 30 2015, 05:21 PM
You may have misunderstood some of the terms used....
Amit Kumar Das Avatar
Posted By Amit Kumar Das
Mon Jun 29 2015, 06:03 PM
Suppose the ILI9320 TFT LSB & MSB pins are con...
prajwalsnh Avatar
Posted By prajwalsnh
Mon Jun 29 2015, 03:39 PM
Hello everyone,I wanted to know the basics of debu...