#include<reg52.h>
unsigned char code du[17]={
0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
void delay(int sum)
{
int x,y;
for(x=sum;x>0;x--)
for(y=110;y>0;y--)
{;}
}
unsigned char key_scan()
{
unsigned char key,key_l,key_h;
P1=0xf0;
key_l=P1;
key_l=key_l&0xf0;
if(key_l!=0xf0)
{
delay(10);
if(key_l!=0xf0)
{
key_l=P1&0xf0;
key_l=key_l|0x0f;
P1=key_l;
key_h=P1;
key_h=key_h&0x0f;
key_l=key_l&0xf0;
key=key_l+key_h;
while(P1!=0xf0);
}
}
return key;
}
void main(void)
{
unsigned char keynum;
P0=0xff;
while(1)
{
keynum=key_scan;
switch(keynum)
{
case(0xee):
P0=du[0];
break;
case(0xde):
P0=du[1];
break;
case(0xbe):
P0=du[2];
break;
case(0x7e):
P0=du[3];
break;
case(0xed):
P0=du[4];
break;
case(0xdd):
P0=du[5];
break;
case(0xbd):
P0=du[6];
break;
case(0x7d):
P0=du[7];
break;
case(0xeb):
P0=du[8];
break;
case(0xdb):
P0=du[9];
break;
case(0xbb):
P0=du[10];
break;
case(0x7b):
P0=du[11];
break;
case(0xe7):
P0=du[12];
break;
case(0xd7):
P0=du[13];
break;
case(0xb7):
P0=du[14];
break;
case(0x77):
P0=du[15];
break;
default:
break;
}
}
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
谢咯 我改后 按键还是没反应 我写的矩阵扫描程序有问题没
一周热门 更多>