Step 4You've got to have some code!
In PWM mode the color is set by applying a pulse width modulated signal the the 3 GPIO pins and multiplexing the 8 LEDs. This reduces overall brightness, but now individual color control is possible. This is done in the background by an interrupt routine. Basic functions are available for setting the LEDs a certain color value, either using an RGB triplet or a HUE value.
The device is programmed in C using the Arduino IDE for convenience. I've attached the current code I use. Up to date versions are available on my blog. You can browse the GIT repository using the gitweb interface. Many stupid programming mistakes will show up, I'm sure of it ;-)
The second figure illustrates PWM generation. A hardware counter counts from BOTTOM to TOP. Once the counter is larger than a certain number representing a desired color, the output is toggled. Once the counter has reached its TOP value, everything is reset. The perceived brightness of the LED is somewhat proportional to the on-time of the signal. Strictly speaking that's a lie, but easier to understand.
| « Previous Step | Download PDFView All Steps | Next Step » |
![]() |
Add Comment
|
















































