3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Bike taillight with a twist

Step 4You've got to have some code!

You\
In high brightness mode the board supports 6 different colors + white. The color is chosen by setting 3 GPIO pins to high or low. That way all eight LEDs can be fully on, but only show the same color.

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 StepDownload PDFView All StepsNext Step »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
26
Followers
2
Author:madworm
Slightly Dorky High Nerd