|
#include<reg51.h>
unsigned char code a[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
sbit w1=P3^6;
sbit w2=P3^7;
void delay(unsigned int xms);
void light(unsigned int t);
int main()
{
while(1){
P1=0x1e;
light(8);
P1=0x1f;
delay(500);
P1=0x1e;
delay(500);
P1=0x1f;
delay(500);
P1=0x1e;
delay(500);
P1=0x1f;
delay(500);
P1=0x1e;
delay(500);
P1=0x1d;
delay(3000);
P1=0x33;
light(8);
P1=0x3b;
delay(500);
P1=0x33;
delay(500);
P1=0x3b;
delay(500);
P1=0x33;
delay(500);
P1=0x3b;
delay(500);
P1=0x33;
delay(500);
P1=0x2b;
delay(3000);
}
return 0;
}
void delay(unsigned int xms)
{ unsigned int k;
unsigned char i,j;
for(k=xms;k>0;k--)
for(i=0;i<10;i++)
for(j=0;j<33;j++);
}
void light(unsigned int t)
{
unsigned int j;
unsigned int x;
unsigned int y;
while(t!=-1)
{
x=t/10;
y=t%10;
for(j=50000;j>0;j--)
{
P2=a[x];
w1=0;w2=1;
w1=1;w2=1;
P2=a[y];
w1=1;w2=0;
w1=1;w2=1;
}
t--;
}
}
|
|