为什么按几下才能显示数字呢
#include<reg52.h>#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
uchar temp,num;
uchar code a[]={0x28, 0x7E, 0xA2, 0x62, 0x74, 0x61, 0x21, 0x7A, 0x20, 0x60};
void delay(uint x)
{
uchar i;
while(x--)
{
for(i=1000;i>0;i--);
}
}
void main()
{
P2=0x00;
while(1)
{
P1=0xfe;
temp=P1;
temp=temp&0xf0;
while(temp!=0xf0)
{
// delay(5);
temp=P1;
temp=temp&0xf0;
while(temp!=0xf0)
{
temp=P1;
switch(temp)
{
case 0xee:num=1;break;
case 0xde:num=2;break;
case 0xbe:num=3;break;
case 0x7e:num=4;break;
}
P0=a[num-1];
while(temp!=0xf0)
{
temp=P1;
temp=temp&0xf0;
}
}
}
P1=0xfd;
temp=P1;
temp=temp&0xf0;
while(temp!=0xf0)
{
//delay(5);
temp=P1;
temp=temp&0xf0;
while(temp!=0xf0)
{
temp=P1;
switch(temp)
{
case 0xed:num=5;break;
case 0xdd:num=6;break;
case 0xbd:num=7;break;
case 0x7d:num=8;break;
}
P0=a[num-1];
while(temp!=0xf0)
{
temp=P1;
temp=temp&0xf0;
}
}
}
}
}