Close

Fading routine

A project log for blinktronicator

Sixteen different LED colors on a teeny tiny board.

zakqwyzakqwy 01/02/2016 at 16:151 Comment

I put together a simple PWM-based fading routine for the LEDs; it's pretty much a pair of functions that run as fast as possible:

updateLEDs(unsigned char ledOutput1, unsigned char ledOutput2)
...updates the current LED state (i.e., on or off), and...
displayFader()
....iterates through a counter to decide whether to turn the LEDs on or off at a given time.

I'm guessing the code could probably be significantly more efficient; I'm still learning a lot about how bitwise operations work and so forth, so comments are absolutely welcome and encouraged. I also added a slower loop to gradually change the LED brightness values sequentially.

When I used the full 8-bit brightness value for each LED, I was able to maintain a ~40 Hz refresh rate according to the 'scope; this produced noticeable flicker, so I reduced the threshold for faderCount to 100. I'd like more rangeability as brightness level 1 still isn't super dim, but it's a start.

Firmware update has been pushed to the repo.

Discussions

[deleted]

[this comment has been deleted]

zakqwy wrote 01/14/2016 at 12:11 point

Thanks!! The current model is fairly delicate.. the new boards arrived yesterday and proper footprints should help that out a lot.

  Are you sure? yes | no