#include<reg52.h>
void Delay(unsigned int n);
void shine_1();
void shine_2();
void shine_3();
void shine_4();
void fun1();
void main()
{
fun1();
}
void Delay(unsigned int n)
{
unsigned int i,j;
for(i = n;i > 0;i--)
{
for(j = n/2;j > 0; j--)
{}
}
}
void fun1()
{
P1 = 0xfe;
Delay(200);
P1 = 0xfd;
Delay(200);
P1 = 0xfb;
Delay(200);
P1 = 0xf7;
Delay(200);
while(1)
{
shine_1();
shine_2();
shine_3();
shine_4();
P1 = 0x3d;
Delay(200);
P1 = 0x7b;
Delay(200);
P1 = 0xf7;
Delay(200);
}
}
void shine_1()
{
unsigned char tmp;
unsigned int i;
tmp =0x10;
for(i = 0;i < 13;i++)
{
P1 = ~tmp;
Delay(200);
tmp <<= 1;
if(tmp == 0)
{
tmp = 0x01;
}
}
}
void shine_2()
{
unsigned char temp;
unsigned int i;
temp = 0x03;
P1 = 0xfe;
for(i = 0;i < 17;i++)
{
if(temp == 0x80)
{
temp = 0x81;
}else if(temp == 0x02)
{
temp = 0x03;
}
P1 = ~temp;
temp <<= 1;
Delay(200);
}
}
void shine_3()
{
unsigned char temp;
unsigned int i;
temp = 0x07;
//P1 = 0xfe;
//Delay(200);
P1 = 0xfc;
for(i = 0;i < 16;i++)
{
Delay(200);
if(temp == 0xc0)
{
temp = 0xc1;
}else if(temp == 0x82)
{
temp = 0x83;
}
else if(temp == 0x06)
{
temp = 0x07;
}
P1 = ~temp;
temp <<= 1;
}
}
void shine_4()
{
unsigned char temp;
unsigned int i;
temp = 0x0f;
P1 = 0xfc;
Delay(200);
P1 = 0xf8;
for(i = 0;i < 16;i++)
{
Delay(200);
if(temp == 0xe0)
{
temp = 0xe1;
}else if(temp == 0xc2)
{
temp = 0xc3;
}
else if(temp == 0x86)
{
temp = 0x87;
}
else if(temp == 0x0e)
{
temp = 0x0f;
}
P1 = ~temp;
temp <<= 1;
}
}
void Delay(unsigned int n);
void shine_1();
void shine_2();
void shine_3();
void shine_4();
void fun1();
void main()
{
fun1();
}
void Delay(unsigned int n)
{
unsigned int i,j;
for(i = n;i > 0;i--)
{
for(j = n/2;j > 0; j--)
{}
}
}
void fun1()
{
P1 = 0xfe;
Delay(200);
P1 = 0xfd;
Delay(200);
P1 = 0xfb;
Delay(200);
P1 = 0xf7;
Delay(200);
while(1)
{
shine_1();
shine_2();
shine_3();
shine_4();
P1 = 0x3d;
Delay(200);
P1 = 0x7b;
Delay(200);
P1 = 0xf7;
Delay(200);
}
}
void shine_1()
{
unsigned char tmp;
unsigned int i;
tmp =0x10;
for(i = 0;i < 13;i++)
{
P1 = ~tmp;
Delay(200);
tmp <<= 1;
if(tmp == 0)
{
tmp = 0x01;
}
}
}
void shine_2()
{
unsigned char temp;
unsigned int i;
temp = 0x03;
P1 = 0xfe;
for(i = 0;i < 17;i++)
{
if(temp == 0x80)
{
temp = 0x81;
}else if(temp == 0x02)
{
temp = 0x03;
}
P1 = ~temp;
temp <<= 1;
Delay(200);
}
}
void shine_3()
{
unsigned char temp;
unsigned int i;
temp = 0x07;
//P1 = 0xfe;
//Delay(200);
P1 = 0xfc;
for(i = 0;i < 16;i++)
{
Delay(200);
if(temp == 0xc0)
{
temp = 0xc1;
}else if(temp == 0x82)
{
temp = 0x83;
}
else if(temp == 0x06)
{
temp = 0x07;
}
P1 = ~temp;
temp <<= 1;
}
}
void shine_4()
{
unsigned char temp;
unsigned int i;
temp = 0x0f;
P1 = 0xfc;
Delay(200);
P1 = 0xf8;
for(i = 0;i < 16;i++)
{
Delay(200);
if(temp == 0xe0)
{
temp = 0xe1;
}else if(temp == 0xc2)
{
temp = 0xc3;
}
else if(temp == 0x86)
{
temp = 0x87;
}
else if(temp == 0x0e)
{
temp = 0x0f;
}
P1 = ~temp;
temp <<= 1;
}
}