uchar kbscan(void)
{
unsigned char sccode,recode;
P1=0x0f; //å0æ«æ,å线è¾å
¥
if ((P2 & 0x0f) != 0x0f) //æé®æä¸
{
delay(20); //延æ¶å»æå¨
if ((P1&0x0f)!= 0x0f)
{
sccode = 0xef; //éè¡æ«æåå¼
while((sccode&0x01)!=0)
{
P1=sccode;
if((P1&0x0f)!=0x0f)
{
recode=(P1&0x0f)|0xf0;
while((P1&0x0f)!=0x0f);//çå¾
é®æ¬èµ·
return((~sccode)+(~recode));
}
else
sccode=(sccode<<1)|0x01;
}
}
}
return 0; //æ é®æä¸ï¼è¿å0
}
温馨提示:答案为网友推荐,仅供参考