Using an RGB LED you can cycle through all colours. Useful to make, Mood Lamp, expressive robot or cool light effects.

But to simply set the colour (Hue) can be a little tricky because you need to convert that to individual brightness value for each of the Red, Green and Blue LEDs.

Wire the circuit as shown below:

Red LED Anode : D3

Green LED Anode : D5

Blue LED Anode : D6

Common Cathode -> 220 Ohm resistor -> Gnd

NOTE: Whist a common Cathode resistor gives you the simplest wiring, the colour matching to the Hue value can be a little inaccurate because the forward Voltage drop of the coloured LEDs is very different. For more accurate colour rendition use 3 220Ohm resistors from the Arduino pins to the Anodes and connect the Cathode directly to Gnd.

Step 1: Hue and Brightness

Hue is a value from 0 to 360 (degrees) that describes the location of the chosen colour on the colour wheel.

See the picture to see the various colours (source: http://en.wikipedia.org/wiki/File:HueScale.svg)
Brightness is controlled separately.

We need some code to convert Hue and Brightness to RGB levels to go to the LEDs.

Note: The max value an 8bit number can hold is 255. So the Hue values are scaled to go from 0 to 255 rather than 0 to 360.

<p>i have finally made it, all I had to do was to set the code to &quot;true&quot;</p><p>here is a video in action; <iframe allowfullscreen="" frameborder="0" height="281" src="//www.youtube.com/embed/ZAJp0k6DLZc" width="500"></iframe></p><p>thank you.!</p>
<p>hello sir, can you tell me by looking at this <a href="http://www.ebay.com/itm/330833693803?_trksid=p2060778.m2749.l2648&ssPageName=STRK%3AMEBIDX%3AIT" rel="nofollow">item </a>if it is a common anode or cathode? thank you!!</p>
<p>That looks like Common Anode. See how <br>pin 1 connects to the Anodes of all the LEDs. This Instructable works <br>with Common Anode LEDs by changing this line in the code:</p><p>const boolean invert = false; // set true if common anode, false if common cathode</p>
<p>ok so what I don't understand is that where does the GND go then??? the R,G,B of the led goes to &quot;Dout&quot; of the arduino, and what about the anode leg? this is where I am confused.. thank you for your reply, i'm a beginner in all of this..</p>
<p>The current flows in the direction of the LED &quot;arrow&quot;. So The Anode would be connected to Vdd and the current flows into the Arduino pins to illuminate the LED.</p>
<p>great thanks, I ordered the RGBs. I'll message back if I can't figure it out once they arrive. thank you very much</p>

About This Instructable




Bio: Technologist, Electronic Engineer, sometime Coderdojo mentor.
More by akellyirl:Arduino Guitar Tuner Using DSP Techniques Add Amazon Echo Voice Control to You Smart Device Smart Home Thermostat 
Add instructable to: