51单片机LED呼吸灯
心灵手巧呼吸灯,学会就能上大分
main.c
#include <REGX52.H>
sbit LED=P2^0;
void Delay(unsigned int i)
{
while(i--);
}
void main()
{
unsigned char Time,i;
while(1)
{
for(Time=0;Time<100;Time++)
{
for(i=0;i<20;i++)
{
LED=0;
Delay(Time);
LED=1;
Delay(100-Time);
}
}
for(Time=100;Time>0;Time--)
{
for(i=0;i<20;i++)
{
LED=0;
Delay(Time);
LED=1;
Delay(100-Time);
}
}
}
}