我的
开发板上的矩阵键盘用行列反转扫描法一切正常,但是运用郭天祥老师的方法就不对了 请问是怎么会儿事 程序如下
P2=0xfe;
a=P2;
a=a&0xf0;
while(a!=0xf0)
{
delay(200);
a=P2;
a=a&0xf0;
while(a!=0xf0)
{
a=P2;
switch(a)
{
case 0xee : num1=0;
break;
case 0xde : num1=1;
break;
case 0xbe : num1=2;
break;
case 0x7e : num1=3;
break;
}
while(a!=0xf0)
{
a=P2;
a=a&0xf0;
}
}
} 故障情况是 右边两列矩阵键盘无效
-
uchar key()
{
uchar temp,tepm1;
P0=0xf0;
temp=P0;
P0=0x0f;
temp1=P0;
switch(temp|temp1)
{
case 0xee: return 0;
case 0xde: return 1;
case 0xbe: return 2;
case 0x7e: return 3;
case 0xed; return 4;
case 0xdd: return 5;
case 0xbd; return 6;
case 0x7d; return 7;
case 0xed; return 8;
case 0xdd: return 9;
case 0xbd; return 10;
case 0x7d; return 11;
case 0xed; return 12;
case 0xdd: return 13;
case 0xbd; return 14;
case 0x7d; return 15;
default: return 16; break;
}
}
一周热门 更多>