请求51单片机c语言关于矩阵键盘扫描程序的详解 谢谢了 部分程序如下 void keyscan(void)
{
char col,row;
char scanline=0x08;
int key=0;
int keystatus;
for(col=0;col<4;col++)
{
P2=~scanline;
keystatus=~P2;
keystatus&=0xf0;
for(row=0;row<4;row++)
{
if(keystatus==0x80)
{
one=0;
if(keytemp!=key)
{
keytemp=key;
zero=1;
}
else
{
zero+=1;
if(zero==5)
keydata=keytemp;
}
}
key+=1;
keystatus<<=1;
}
}
one+=1;
if(one==5)
{
zero=0;
keytemp=0xff;
keydata=0xff;
}
}
|