
#include"reg51.h"
#define uchar unsigned char
#define uint unsigned int
uchar dd[]={
0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f
};
void delay(uchar us)
{
uchar m,n;
while(us--)
{
for(m=0;m<10;m++)
for(n=0;n<40;n++);
}
}
void display(uint court)
{
uchar i;
for(i=0;i<20;i++)
{
P0=dd[(court%1000)/100];
P3=dd[(court%1000)/100];
P2=0xb4;
delay(5);
P2=0xf0;
delay(1);
P0=dd[((court%1000)%100)/10];
P3=dd[((court%1000)%100)/10];
P2=0xd2;
delay(5);
P2=0xf0;
delay(1);
P0=dd[court%10];
P3=dd[court%10];
P2=0xe1;//
delay(5);
P2=0xf0;
delay(1);
}
}
void main()
{
uint dat;
uchar i;
while(1)
{
display(dat);
dat++;
if(dat==1000)dat=0;
}
}
|