大神,帮忙看看程序是哪儿的原因??
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
给你看看我以前写的一个51下的,你参考一下方法。
/***************¼üÅÌɨÃè³ÌÐò*************************/
unsigned char key()
{
KeyPort=0xf0;
if((KeyPort&0xf0)!=0xf0)
delaynms(5);
if((KeyPort&0xf0)!=0xf0)
{
KeyPort=0xfe;
switch(KeyPort)
{
case 0xee:KeyVal=0;break;
case 0xde:KeyVal=1;break;
case 0xbe:KeyVal=2;break;
case 0x7e:KeyVal=3;break;
}
KeyPort=0xfd;
switch(KeyPort)
{
case 0xed:KeyVal=4;break;
case 0xdd:KeyVal=5;break;
case 0xbd:KeyVal=6;break;
case 0x7d:KeyVal=7;break;
}
KeyPort=0xfb;
switch(KeyPort)
{
case 0xeb:KeyVal=8;break;
case 0xdb:KeyVal=9;break;
case 0xbb:KeyVal=10;break;
case 0x7b:KeyVal=11;break;
}
KeyPort=0xf7;
switch(KeyPort)
{
case 0xe7:KeyVal=12;break;
case 0xd7:KeyVal=13;break;
case 0xb7:KeyVal=14;break;
case 0x77:KeyVal=15;break;
}
}
return KeyVal;
}