Thursday, October 13, 2011

Video of LED fade in/out

For details of the following vid see yesterday's LED fading using exponentially changing PWM duty cycle. However, because the dimming wasn't as smooth as I wanted it to be, I changed a couple of items.

1. I used 32 pulse width values instead of 16. And so the look-up table for this demo is:
const char PW[] = {0, 0, 1, 1, 1, 2, 2, 3, 4, 5, 6, 7, 9, 10, 12, 15, 18, 22, 26, 31, 37, 44, 53, 63, 75, 90, 107, 127, 151, 180, 214, 255};

2. To preserve the 655ms total time from zero to maximum brightness I halved the timer2 postscale to 1:5.

3. Because of the increase in PW values, the constant in one of the conditional statements had to be changed from 15 to 31:
if (direction && ++i > 31).

No comments:

Post a Comment