#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar code table[16]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,
0x77,0x7c,0x39,0x5e,0x79,0x71};
uchar code LED_W[8]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xdf,0x7f};
void delay(uint i)
{
uint x,j;
for(x=0;x<i;x++)
for(j=0;j<148;j++)
{}
}void main()
{
uchar i,j;
while(1)
{
for(j=0;j<100;j++)
{ P0=0;
P2=0xfb;
P0=table[i/100];
delay(3);
P0=0;
P2=0xfd;
P0=table[(i/10)%10];
delay(3);
P0=0;
P2=0xfe;
P0=table[i%10];
delay(3);
}
if(i!=999)
{
i++;
}
else
{
i=0;
}
}
} |