⑴ proteus键盘输入实现四位数码管显示的c语言代码怎么写
#include<reg52.h>
#defineucharunsignedchar
#defineuintunsignedint
ucharcodetable[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71,0x00};//0-f-最后一个空
ucharj=1;
sbitp37=P3^7;
voiddelay(uintz)
{
uintx,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
voiddisplay(ucharshu)
{
P1=table[shu];
delay(5);
}
ucharkeyscan()
{
uchartemp,num;
P2=0xfe;
temp=P2;
temp=temp&0xf0;
if(temp!=0xf0)
{
p37=0;
delay(5);
temp=P2;
temp=temp&0xf0;
while(temp!=0xf0)
{
temp=P2;
switch(temp)
{
case0xee:num=1;break;
case0xde:num=2;break;
case0xbe:num=3;break;
default:break;
}
while(temp!=0xf0)//**********松手检测松手后显示
{
j=0;
temp=P2;
temp=temp&0xf0;
}
}
}p37=1;
P2=0xfd;
temp=P2;
temp=temp&0xf0;
if(temp!=0xf0)
{
p37=0;
delay(5);
temp=P2;
temp=temp&0xf0;
while(temp!=0xf0)
{
temp=P2;
switch(temp)
{
case0xed:num=4;break;
case0xdd:num=5;break;
case0xbd:num=6;break;
}
while(temp!=0xf0)
{
j=0;
temp=P2;
temp=temp&0xf0;
}
}
}p37=1;
P2=0xfb;
temp=P2;
temp=temp&0xf0;
if(temp!=0xf0)
{
p37=0;
delay(5);
temp=P2;
temp=temp&0xf0;
while(temp!=0xf0)
{
temp=P2;
switch(temp)
{
case0xeb:num=7;break;
case0xdb:num=8;break;
case0xbb:num=9;break;
}
while(temp!=0xf0)
{
j=0;
temp=P2;
temp=temp&0xf0;
}
}
}p37=1;
P2=0xf7;
temp=P2;
temp=temp&0xf0;
if(temp!=0xf0)
{
p37=0;
delay(5);
temp=P2;
temp=temp&0xf0;
while(temp!=0xf0)
{
temp=P2;
switch(temp)
{
case0xe7:num=16;break;
case0xd7:num=0;break;
case0xb7:num=16;break;
}
while(temp!=0xf0)
{
j=0;
temp=P2;
temp=temp&0xf0;
}
}
}p37=1;
//if(j==1)num=16;
returnnum;
}
voidmain()
{
p37=1;
while(1)
{
display(keyscan());
//display(7);
}
}
我写的简单键盘程序并有数码管显示仿真结果如图所示你可以按照图示实验有什么问题可以共同讨论