#include
sbit LED0=P0^0;
sbit wei=P1^1;
sbit duan=P1^0;
sbit lcden=P1^7;
sbit dianzhen=P1^3;
sbit leden=P1^2;
void Delay(unsigned int t);
void main (void)
{
unsigned int CYCLE=600,PWM_LOW=0;//定义周期并赋值
lcden=0;
P0=0x00;
dianzhen=0;
P0=0xff;
wei=0;
duan=0;
while (1) //主循环
{
LED0=1;
Delay(150000); //特意加延时,可以看到熄灭的过程
for(PWM_LOW=1;PWM_LOW
LED0=0;
Delay(PWM_LOW);
LED0=1;
Delay(CYCLE-PWM_LOW);
}
for(PWM_LOW=CYCLE-1;PWM_LOW>0;PWM_LOW--)
{
LED0=0;
Delay(PWM_LOW);
LED0=1;
Delay(CYCLE-PWM_LOW);
}
}
}
void Delay(unsigned int t)
{
while(t--);
}