Blazemaguire
Senior Member
Hi,
I've adapted some code I found in a previous post regards fading an LED up - It works in a nice controlled manner and with some playing, now has the effect I want, however, I get an annoying 'pre flicker' before the main fade up kicks in. i.e, a very quick low brightness 'blip' and then the LEDs fade up as expected.
Does anyone have any insight into what's causing the flicker in the code?
Is it the pwmout command after the init: routine declaration? to my knowledge, that part needs to be there otherwise the other PWMduty command doesn't work. - Does anyone have any tips or workarounds that might get rid of the flicker? or am I dealing with a hardware issue and barking up the wrong tree?
thanks
Rob
I've adapted some code I found in a previous post regards fading an LED up - It works in a nice controlled manner and with some playing, now has the effect I want, however, I get an annoying 'pre flicker' before the main fade up kicks in. i.e, a very quick low brightness 'blip' and then the LEDs fade up as expected.
Does anyone have any insight into what's causing the flicker in the code?
Is it the pwmout command after the init: routine declaration? to my knowledge, that part needs to be there otherwise the other PWMduty command doesn't work. - Does anyone have any tips or workarounds that might get rid of the flicker? or am I dealing with a hardware issue and barking up the wrong tree?
thanks
Rob
Code:
symbol val = w0
symbol pwmPin = c.2 ;led array
symbol fade_rate=4
init:
pwmout pwmdiv4, pwmPin, 249, 500
;set PWM
main: ;loop to fade led array using PWM
val = 0
do
pwmduty pwmPin, val ; set pwm duty
val = val +fade_rate 'increase this to increase the fade rate
'
pause 1 'defines how quickly the fade down occur as well
'
if val = 1000 then pwmout pwmpin,off high pwmpin
endif
loop