这是源程序:
#include<reg51.h>
#define uint unsigned int
#define uchar unsigned char
uchar code KEY_TABLE[]={0x11,0x21,0x12,0x22};
uchar code a[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
uchar code b[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
uchar code c[]={0xfe,0xfd,0xfb,0xf7,0xef};
void delay5ms(uint x)
{
uchar t,ms;
ms=25*x;
while(ms--)
for(t=0;t<120;t++);
}
void delays()
{
uint s=10000;while(s--);
}
void main()
{
uchar n,x,temp,key,num,i,j;
n=0;
x=5;
j=0;
for(;;)
{
if(j==0)
{
P1=a[n];
}
P0=c[x-1];
delay5ms(x);
n=n+1;
if(n==8)
n=0;
P3=0xf0;
if(P3!=0xf0)
{
delays();P3=0xf0;
if(P3!=0xf0)
{
temp=P3;
P3=0x0f;
key=temp|P3;
key=0xff-key;
for(i=0;i<4;i++)
{
if(key==KEY_TABLE)
{
num=i;
break;
}
}
if(num==0)
j=0;
if(num==1)
j=n;
if(num==2)
x=x-1;
if(num==3)
x=x+1;
}
}
}
}
为什么这时的P1不能正常输出??? |