Tuesday, June 9, 2009

Keyboard interfacing program.....

/********** Keyboard Interface ***********/

#include
#include "lcd.h"
unsigned char getkey();
void delay(unsigned int);
main()
{
unsigned char key;
InitLcd();
WriteString("Key Pressed=");
while(1)
{
GotoXY(12,0);
key = getkey();
}
}

unsigned char getkey()
{
unsigned char i,j,k,indx,t;
P0=0x0ff;
P2 = 0x00;
indx = 0x00;
for(i=0x00E;i>=0x00B;i<<=1)
{
P2 = i;
t = P0;
t = ~t;
if(t>0)
{
delay(6000);
for(j=0;j<=7;j++)
{
t >>=1;
if(t==0)
{
k = indx+j;
t = k>>4;
t +=0x30;
WriteChar(t);
t = k & 0x0f;
if(t > 9)
t+=0x37;
else
t+=0x30;
WriteChar(t);
return(indx+j);
}
}
}
indx += 8;
}
}

void delay(unsigned int x) /
{
for(;x>0;x--);
}

/********END******/
plzz include reg51.h in ur program its not getting posted in blog...
Hey guys to interface keyboard use this program....given in manual is wrong....
I also got same experiment and got the output for this program.....
 

hit counter