Is your PWM 8bit, with values 0-255?
Why do you use increase by 10 and why do you decrease by 80 and then 70..60 .. etc
a value of 150 will become 160,170,180,190,200,210,220,230 and then 230-80, 150-70, 80-60..
Is this what you want to do?
Code C - [expand] |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| pwmplus=80;
for(lvl=0; lvl<=16; lvl++)
{
if (lvl<8)
{
Pwm1_Change_Duty(pwmplus); // 80,90,100,110,120,130,140,150
pwmplus+=10;
}
else
{
pwmplus-=10;
Pwm1_Change_Duty(pwmplus); // 140,130,120,110,100,90,80,70,60
}
Delay_ms(1);
} |
Alex