unsigned char Keyscan(void)
{
unsigned char x,y,Key_back=0;
SCAN_IO=0x0f;
if(SCAN_IO!=0x0f)//读取按键是否按下
{
Delay10ms(10);//延时10ms进行消抖
if(SCAN_IO!=0x0f)//再次检测键盘是否按下
{
x = SCAN_IO;
SCAN_IO=0xf0;
y = SCAN_IO;
x = x|y;
switch(x)
{
case(0Xe7): {Key_back=1;}break;
case(0Xeb): {Key_back=2;}break;
case(0Xed): {Key_back=3;}break;
case(0Xee): {Key_back=4;}break;
case(0Xd7): {Key_back=5;}break;
case(0Xdb): {Key_back=6;}break;
case(0xdd): {Key_back=7;}break;
case(0Xde): {Key_back=8;}break;
case(0Xb7): {Key_back=9;}break;
case(0Xbb): {Key_back=10;}break;
case(0Xbd): {Key_back=11;}break;
case(0Xbe): {Key_back=12;}break;
case(0X77): {Key_back=13;}break;
case(0X7b): {Key_back=14;}break;
case(0X7d): {Key_back=15;}break;
case(0X7e): {Key_back=16;}break;
default:Key_back=0;break;
}
}
}
return(Key_back);
}
-
一周热门 更多>