直接上代码。
void timeInte0() interrupt 1
{
pwm_count++;
huxideng++;
if(pwm_count==pwm_value) led=0x00;//open
if(pwm_count==99)
{
led=0xff;//close
pwm_count=0;
}
if(huxideng==600&&flag==0)
{
huxideng=0;
pwm_value++;//Ôö¼ÓÕ¼¿Õ±Èʱ¼ä
if(pwm_value==100)
flag=1;//ת»»·½Ïò
}
if(huxideng==600&&flag==1)
{
huxideng=0;
pwm_value--;//Õ¼¿Õ±È¼õÉÙ
if(pwm_value==1)
flag=0;
}
}