How to Use an RGB LED

Picture of How to Use an RGB LED
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.
Remove these adsRemove these ads by Signing Up

Step 1: Hue and Brightness

Picture of 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:
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.


Get More Out of Instructables

Already have an Account?


PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!