Quote Originally Posted by ruijc View Post
Hi all,

I have a question regarding PWM.
I'm using PWM to fade in/out a LED on a 12F675 with the code below.

Code:
For steps=255 TO 1 STEP -1
pwm white,steps,2
Next
I'm looking for a linear result but is not working.
When the led is almost off the speed increases ( which is obvious since the pic is using less bits to count ).

My question is, is there a workarround to minimize this effect and make the fade out/in more linear ?

Thanks
I think the code is producing a linear change in PWM duty cycle. What you're perceiving as being non-linearity is probably a result of the fact that LED (and most lamps in general) brightness do not change linearly with a change in voltage.

You should actually be trying to create a logarithmic rate of change in order to produce a linear change of brightness