Hello,
I'm trying to stop increasing duty even if I press the button.
But it works only when I set max ~120 in the code. If I set more, then it just goes to max and jump to min again. I totally dont understand why I'm not able to do that.
Here is my code
I'm trying to stop increasing duty even if I press the button.
But it works only when I set max ~120 in the code. If I set more, then it just goes to max and jump to min again. I totally dont understand why I'm not able to do that.
Here is my code
Thank youvoid main()
{
short duty1 = 0;
TRISD = 0xFF;
TRISC = 0x00;
PWM1_Init(5000);
PWM1_Start();
PWM1_set_duty(duty1);
while (1)
{
if (PORTD.F0==0)
{Delay_ms(1);
duty1++;
if (duty1>200) duty1=200; // here I set the max duty
PWM1_set_duty(duty1);
}
if (PORTD.F1==0)
{
Delay_ms(1);
duty1--;
PWM1_set_duty(duty1);
}
Delay_ms(10);
}
}