How can I change the color of a RGB LED with the push of a button (i.e., push once for red, again for green, etc.).

I have to laugh when I see the prices of flashlights that have multiple LED colors. $50 for a headlamp with 6 RGB LEDs?  Really?  I have seen "Buy It Now"s on eBay that have 50 pcs of RGB LEDs for ~$17.  Besides, the fun is in building one myself.

sort by: active | newest | oldest
lemonie8 years ago
You want to cycle through 3 colours with a single push button - some kind of microcontroller would be in order. Unless you can get a rotary switch that works on a push (like a ballpoint pen)?

CasCom98 (author)  lemonie8 years ago
I like that idea.  I have a flashlight that has that (off-LED-Laser).  What are they called.  I tried to find them online, but can't seem to find exactly that.  I would need one with an off and 4 "on".  I will be using RGB LEDs (3 in 1 package, shared anode), UV LEDs and a krypton bulb.
The push-rotary is simplest if you can find one, or maybe just a rotary. Otherwise it gets more complicated. I think of motorbike gears - one way up, the other down - click, click, click...

seandogue8 years ago
switching could be done with clever use of a 4 bit counter chip and a multiplexer

Hint: use the pushbutton as the clock source thru a Schmidtt trigger (to debounce clk> )
0 - off
1 - R
2 - G
3 - B
4 - reset
Are you comparing LEDs of the same specification. I can pick up 0605 (surface mount) RGB LEDS for your kind of prices, but they are slightly bigger than a grain of sugar.....

What you want to do is do-able with simple logic, but depends on the wiring of the LED. Are you going to use separate RGB elements, or are they arranged with common wires, or back-to-back ? 

Marsh8 years ago
 This is how a DPDT switch would be used to accomplish the task.
NachoMahma8 years ago
.  A DPDT switch or relay will swap polarity.