#include<reg52.h>
typedef unsigned int uint;
typedef unsigned char uchar;
void Delay(uint t)
{
while(--t);
}
void main(void)
{
uchar LED;
uint Time=600,i=0;
LED=0xfe;
while(1)
{
for(i=1;i<Time;i++)
{
P2.0=LED;
LED=LED<<1;
if(LED == 0x00)
{
P2.0=LED;
Delay(i);
P2.0=~(LED);
Delay(Time-i);
}
}
for(i=Time-1;i>0;i--)
{
P2.0=LED;
LED=LED<<1;
if(LED == 0x00)
{
P2.0=LED;
Delay(i);
P2.0=~(LED);
Delay(Time-i);
}
}
}
}
|