#include<reg52.h>
#define dataport P0
#define uchar unsigned char
#define uint unsigned int
sbit latch1=P2^2;
sbit latch2=P2^3;
uchar code duanma[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
uchar code weima[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
void delay(uint t);
void main()
{
uchar i=0,num;
uint j;
while(1)
{
dataport=weima[ i];
latch2=1;
latch2=0;
dataport=duanma[num+i];
latch1=1;
latch1=0;
delay(200);
i++;
j++;
if(8==i)
i=0;
if(j==500)
{
j=0;
num++;
if(num==9)
num=0;
}
}
}
void delay(uint t)
{
while(--t);
}
|