51单片机实现寄存器PWM的呼吸灯

直接上代码。

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;
	}
	
}

猜你喜欢

转载自blog.csdn.net/qq_46069852/article/details/121550203