This was one of the first codes I ever wrote to understand how to use variable analog outputs to dim LEDs.
I got a couple tri-colour LEDs in my Arduino kit, and once I realized they were common anode rather than common cathode, I thought this would be a cool use for it.
The cycle basically does a transition starting with blue. It then goes to blue and red, then fades the blue so there's just red. Then it transitions to red and green, then to just green, then to green and blue, then to just blue, and starts over.
Initially I put a paper sleeve around the LED because the LED is really bright and blinded my cameras, and just showed up white.
Then I thought that made a really nice ornamental lamp that way.
I also put it through a laser etched crystal with the image of a cat on a branch in it.
The effects were pretty cool!
The LED simply hooks up to pins 9, 10, and 11 on the arduino and to either ground or 5V depending on if the LED is common cathode or anode through a current limiting resistor (I suggest 100-220 ohms).
Of course you can also use 3 individual LEDs with one anode each in pins 9, 10 and 11 and the other pins to ground though a current limiting resistor each.
If you're wondering about the penny on my Arduino, see my instructable on Beefing Up your Arduino Power.
A copy of my code was posted as a response to someone else's instructable here:
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Participated in the
Pocket Sized Electronics