hi all

thanks for help

You can choose one of two methods:

- keyboard scan
- interrupt program

If your project is not too complex, the first method is better (easily understand and implement).
If your project requires to save your I/O ports (save your address space), the second one is better. In this case you should study how to write an interrupt procedure.

good luck,

Pls see whether the following articles will help or not:

Originally Posted by From an article
Software Interface
In this section, we will show how the scan code is generated using a Software Interface. As stated before, the keyboard switches are arranged in a matrix of rows and columns. To show how a scan code can be generated using a software interface we shall take, as an example, the hexadecimal keypad.

Circuit Description
* The keypad Switches are connected in a matrix of rows and columns :
-The rows of the matrix are connected to four output port lines.
-The columns of the matrix are connected to four input port lines.
-For simplicity, the rows of the matrix are connected to four input lines.

* When no key is pressed, the column lines are high.

* When a key is pressed, it connects a row to a column.

* If a row is at low and a key in that row is pressed, this low will appear on the column that contains the pressed key and it can be detected on the input port.

* If we can determine the row and column of a key, then we can determine which key it is and so we can assign to it an ASCII code.

Algorithm Description
The following Algorithm shows how to determine the row and column of a key and generate its Scan code:

1-Step One : Output Zero’s to all rows.

2-Step Two : This step consists of a Loop in which we read columns over and over until the columns are all high. We do this to make sure that the previous key has been released before we look for the next one. This is called Two-key lockout.

3-Step Three : Upon exit from Step Two, control goes to this step which is also a Loop. This loop reads columns over and over until one column is low which indicates that a key has been pressed.

4-Step Four : Upon exit from the previous loop, a check is done to avoid the effect of noise. During this stage, columns are read so that if they are high again, this means that the low detected in the step Three was caused by a noise rather than a key press. In this case, control goes back to step Two otherwise step Five is executed.

5-Step Five: Once we reach this step, we need to determine the row and column of the pressed key. This is done in this step which is also a LOOP. In this loop, a low is output on one row and then columns are checked. The loop continues until a low on a column is detected. The row of the pressed key is the row which is low at this moment and its column is the low column.

At this stage we can determine the Scan code which is the 8-bit read from the input port. It consists of D0..D3 which represents the column of the pressed key and D4..D7 which is the row of the pressed key.

hi

i want to make keypad scanning (software)...............but can u givemore details about how can i do it

thanks for help

•

5. ## key pad interfacing program for arm at91sam7s256

write 3 routines:
1) getRowValue
- drive columns low sequentially
- for each column driven low look for 2 rows (max) being low (this way you can implement chording)
2) getKey
- this calls routine 1 and returns max 2rows 2 columns = 2 keys pressed at the same time
- this is your control algoritm

You can also maintain an array of rows x columns and mask it against a previously scanned version of the array to get the changes in keys
cheers

6. ## keypad interface what is

Originally Posted by asic1984
hi

i want to make keypad scanning (software)...............but can u givemore details about how can i do it

thanks for help
Which language are you using?

If you are using C and the CCS compiler there are examples that come with the compiler. In this case take a look at them ...

best regards

•

7. ## keypad on parallel port

this is my sample code, very easy to understand:

***************
+--+--+--+--+
| 1 | 2 | 3 | A |
+--+--+--+--+
| 4 | 5 | 6 | B |
+--+--+--+--+
| 7 | 8 | 9 | C |
+--+--+--+--+
| * | 0 | # | D |
+--+--+--+--+
****************
// declare the variable first, i jump straight to the program
while(!kbhit()) {
for(i=0; i<4; i++) {
p1 = 0xff & ~((1<<4) << i);
// send p1 to IO where keypad is connected, for example GPIO
setgpio(0x47, p1); // set row first, can use outportb() instead, send data to that index
for(j=4; j<8; j++) { // scan keypress here
c = getgpio(0x46); // read data from index, can use inportb()
// results of keypress...
switch(c) {
// row 1
case 0xee: printf("1 pressed."); delay(250); break; // put delay to avoid printing several times
case 0xed: printf("2 pressed."); delay(250); break;
case 0xeb: printf("3 pressed."); delay(250); break;
case 0xe7: printf("A pressed."); delay(250); break;

// row 2
case 0xde: printf("4 pressed."); delay(250); break;
case 0xdd: printf("5 pressed."); delay(250); break;
case 0xdb: printf("6 pressed."); delay(250); break;
case 0xd7: printf("B pressed."); delay(250); break;

// row 3
case 0xbe: printf("7 pressed."); delay(250); break;
case 0xbd: printf("8 pressed."); delay(250); break;
case 0xbb: printf("9 pressed."); delay(250); break;
case 0xb7: printf("C pressed."); delay(250); break;

// row 4
case 0x7e: printf("* pressed."); delay(250); break;
case 0x7d: printf("0 pressed."); delay(250); break;
case 0x7b: printf("# pressed."); delay(250); break;
case 0x77: printf("D pressed."); delay(250); break;

default: break;
}
}
}
}

***note: setgpio() and getgpio() function was created to easily set and read data to/from index, of course you can create your own function with outportb() and inportb() - easy task! (is it??)

I hope you can understand what is the code all about.

best regards,
Triple_X, MY
Jom lawat Terengganu Kiteee :D

2 members found this post helpful.

hi

thanks all for help

for nicleo: is this algorithm mean that i will connect the keypad directlly to parallel port without any interfacing to pullup resistors and positive supply voltage as what i already do (but characters are not reading correctly)

also how can i overcome debounce problem

if someone can send schematic for the connection

and thanks all for help

•

9. ## explain 3 x 4 array keypad matrix explain pdf

Originally Posted by asic1984
for nicleo: is this algorithm mean that i will connect the keypad directlly to parallel port without any interfacing to pullup resistors and positive supply voltage as what i already do (but characters are not reading correctly)

also how can i overcome debounce problem

if someone can send schematic for the connection

and thanks all for help
For parallel port interfacing to keypad, I think you need pullup resistors as shown in Figure 1. You may also wish to read this INTERFACING WITH THE KEYPAD A MORE COMPLEX PARALLEL PORT EXAMPLE http://moi.unl.edu/classes/ee222F04/handouts/keypad.pdf

Switch Debouncing (hardware)
http://engnet.anu.edu.au/DEcourses/e...qdesnode9.html

Switch Decouncing (software)
http://www.hkln.net/doc/8051/example/debounce/index.htm

hi

thanks every one for your help

it works now

hi

U can try with a keypad encoder also.
Its not nessary to scan or poll. U can find the key when its pressed using the interrupt
U can use the IC MM74C922 . even a layman can do the program using this

Have a nice day

Regards
Gopi

12. ## 4x4 matrix keypad scanning in c

just want to say that this topic helped me a lot

thanks for all

13. ## noise generated by keypad

HI
I have problem with keypad interrupt. my 8051 colums comes from one port and rows from anther port and it havng one encoder interrupt from 74HCT21 how to scan this key pad using C rograming. pls help me out

wahid

14. ## matrix keypad scanning in c

learn
8051 microcontrollers
I SCOTT MACKENZIE or
microcontrollers and interfacinmg
by
HALL

hi
how to use the 4x3 keypad?

Originally Posted by akoangsimula
hi
how to use the 4x3 keypad?
You have asked the same question in 11 different threads in this forum in the last 2 hours,
don't you think that 1 or 2 posts are enough?

Alex

Originally Posted by alexan_e
You have asked the same question in 11 different threads in this forum in the last 2 hours,
don't you think that 1 or 2 posts are enough?

Alex

•