guys can you help me if you have sample program regarding on my topic...i have a running LED fade project...pls help me
thanks
PWM chaser using pic16f877 help!
Re: PWM chaser using pic16f877 help!
Just in case anyone comes across this looking for an example.
Fade up, fade down
Fade up, fade down
Code: Select all
Sub procedure Fade
Fade_Up = 1
While Fade_Up < 40
Fade_Loop = 0
While Fade_Loop < 3
PortB = 0
i = 40 - Fade_Up ' Off Loop
While i > 0
delay_us(350)
Dec (i)
Wend
PortB = 0xFF
i = Fade_Up ' On Loop
While i > 0
delay_us(350)
Dec (i)
Wend
Inc (Fade_Loop)
Wend ' do this 3 times
Inc (Fade_Up) ' do this 40 times
Wend ' total 120 times 20ms
'---------------------------------------------
delay_ms(1000)
'---------------------------------------------
Fade_Dn = 1
While Fade_Dn < 40
Fade_Loop = 0 ' Each Loop is 20 ms (40* 500uS)
While Fade_Loop < 3
PortB = 0xFF
i = 40 - Fade_Dn ' Off Loop
While i > 0
delay_us(150)
Dec (i)
Wend
PortB = 0
i = Fade_Dn ' On Loop
While i > 0
delay_us(300)
Dec (i)
Wend
Inc (Fade_Loop)
Wend ' do this 3 times
Inc (Fade_Dn) ' do this 40 times
Wend ' total 120 times 20ms
delay_ms(500)
RETURN
end sub