Scanning of Keypad in C
Here...this articels how to scanning keypad 4X4, i use this for 8051 family microcontroller,keypad on Port 1, you can also use the other exp. AT89S51, AT89s8252 etc, the schematic you can draw by your self, if any question you can send some comments to discust with our team....download-->learn-->try-->practice-->enjoy...
#include <reg8252.h>
#include <stdio.h>
char code column[] = {0xbf,0xdf,0xef};
void keypad (void) interrupt 2
{
char x, key;
unsigned int k;
EX1 = 0;
P1 = 0xff;
for (x=0; x<3; x++)
{
P1 = column[x];
for(k=0;k<0xff;k++);
if ((P1&0x0f) != 0x0f)
{
key = P1;
switch(key)
{
case 0xb7 : putchar('1');break;
case 0xd7 : putchar('2');break;
case 0xe7 : putchar('3');break;
case 0xbb : putchar('4');break;
case 0xdb : putchar('5');break;
case 0xeb : putchar('6');break;
case 0xbd : putchar('7');break;
case 0xdd : putchar('8');break;
case 0xed : putchar('9');break;
case 0xbe : putchar('*');break;
case 0xde : putchar('0');break;
case 0xee : putchar('#');break;
}
}
}
for(k=0;k<0xffff;k++);
P1 = 0x0f;
EX1 = 1;
}
void main (void)
{
EA = 1;
EX1 = 1;
IT1 = 1;
P1 = 0x0f;
while (1);
}
Visitors :60082 Org
Hits : 168173 hits
Month : 2078 Users