4x4矩阵按键,为什么0~3(第一行的四个按键)的按键值怎么都显示不了,剩下的12个按键值都能显示,这是为什么,希望懂的大神能给分析一下,万分感谢!
void main()
{
u8 key=0;
LCD_Init();
LCD_POS(0,0);
LCD12864_disp("请输入");
LCD_POS(1,0);
while(1)
{
key=KeyPro();
if(key!=16)
{
LCD_Writedata(key+'0');
}
}
}
u8 Keyscanf()
{
u8 cord_l=0x0f,cord_h=0xf0;
KEY=0x0f;
if(KEY!=0x0f)
{
Delay_MS(10);
if(KEY!=0x0f)
{
cord_l=KEY&0x0f;
KEY=cord_l|0xf0;
cord_h=KEY&0xf0;
while((KEY&0xf0)!=0xf0);
}
}
return (cord_l|cord_h);
}
u8 KeyPro()
{
u8 key_value=16;
switch(Keyscanf())
{
case 0x77: key_value=0; break;
case 0x7b: key_value=1; break;
case 0x7d: key_value=2; break;
case 0x7e: key_value=3; break;
case 0xb7: key_value=4; break;
case 0xbb: key_value=5; break;
case 0xbd: key_value=6; break;
case 0xbe: key_value=7; break;
case 0xd7: key_value=8; break;
case 0xdb: key_value=9; break;
case 0xdd: key_value=10; break;
case 0xde: key_value=11; break;
case 0xe7: key_value=12; break;
case 0xeb: key_value=13; break;
case 0xed: key_value=14; break;
case 0xee: key_value=15; break;
}
return key_value;
} |