unsigned char keyscan()
{
unsigned char com,com1,com2,i;
keyport=0xf0;
while(keyport!=0xf0)
{
delayms(10);
keyport=0xf0;
while(keyport!=0xf0)
{
keyport=0xf0;
if(keyport!=0xf0)
{
com1=keyport;
keyport=0x0f;
com2=keyport;
}
com=com1|com2;
if(com==0xee)i=12;
if(com==0xde)i=8;
if(com==0xbe)i=4;
if(com==0x7e)i=0;
if(com==0xed)i=13;
if(com==0xdd)i=9;
if(com==0xbd)i=5;
if(com==0x7d)i=1;
if(com==0xeb)i=14;
if(com==0xdb)i=10;
if(com==0xbb)i=6;
if(com==0x7b)i=2;
if(com==0xe7)i=15;
if(com==0xd7)i=11;
if(com==0xb7)i=7;
if(com==0x77)i=3;
}
}
return(i);
}
|