PWM and LED Problem
Wolf
Posts: 1
I have a LED that fades from·OFF to ON
I start by setting the pin LOW then running the pwm 0 - 255 and finish by setting the pin to HIGH.
It fades just fine except for one transition.· The problem occurs when it goes from 255 to HIGH.· It seems to jump in brightness as if the PWM stopped at 225 and then went HIGH.· Now I know this is not the case but its the best way I can explain the amount of brightness jump that is happening.·
I just need to know why it does this and how I can stop it from happening.· Here is the code:
LOW 1 ' LED completely off
FOR B2 = 0 TO 255 ' Loop from off to on.
PWM 1, B2,5 ' Output one burst of pwm.
NEXT
HIGH 1 ' Leave LED on. (this is where the brightness jump happens)
I start by setting the pin LOW then running the pwm 0 - 255 and finish by setting the pin to HIGH.
It fades just fine except for one transition.· The problem occurs when it goes from 255 to HIGH.· It seems to jump in brightness as if the PWM stopped at 225 and then went HIGH.· Now I know this is not the case but its the best way I can explain the amount of brightness jump that is happening.·
I just need to know why it does this and how I can stop it from happening.· Here is the code:
LOW 1 ' LED completely off
FOR B2 = 0 TO 255 ' Loop from off to on.
PWM 1, B2,5 ' Output one burst of pwm.
NEXT
HIGH 1 ' Leave LED on. (this is where the brightness jump happens)
Comments
Another thing that may help is to add an electrolytic capacitor across the LED's leads. This will maintain some current drive between PWMs.
-Phil