Advertisement
arduino rgb led circuit

Arduino RGB LED Color Wand

Here is an artistic Arduino project for the fun-minded. The circuit is an Arduino RGB LED controller running on a sweet ‘n’ simple code,but with a little hardware surprise outside the Arduino board. You can add a bit of luxury to your aquarium or flower vase using this digital color wand!

Here, D11-D10-D9 pins of Arduino is used to drive the Red, Green, Blue Anodes of the common-cathode RGB LED (L1) through independent 270 Ohm current limiting resistors (R1-R3). Common cathode of the RGB LED is routed to ground rail (0V) through a 60NF06 power mosfet (T1). The inclusion of T1 allows you to switch on and/or switch off the light effect using two pushbutton switches (S1-S2).

At first glance, you may think such a powerful mosfet is superfluous here, but the selection is intentional. Note that when the Arduino is powered it starts working as per the code, but the RGB LED action is based on the input status (on/off) given through the pushbutton switches. Experienced hoobyists can “hack” the mosfet section to add many interesting features, without changing the original Arduino Code. The whole circuit can be safely powered from any Arduino AC mains adaptor/9V battery as usual. In the prototype, a “glue stick” (of a glue gun) is used to heighten the visual effect by attaching it to the top of the RGB LED as shown in the photograph.

Schematic of the Arduino RGB LED Circuit

arduino rgb led circuit

Arduino Sketch Code

/*
Arduino Color Wand -RGB LED
*/
int rledPin = 11;
int gledPin = 10;
int bledPin = 9;
void setup()
{
   pinMode(rledPin, OUTPUT);
   pinMode(gledPin, OUTPUT);
   pinMode(bledPin, OUTPUT);
}
void loop()
{
   setColor(255, 0, 0); / / Red
   delay(2000);
   setColor(80, 0, 80); / / Purple
   delay(2000);
   setColor(0, 255, 0); / / Green
   delay(2000);
   setColor(255, 255, 0); / / Yellow
   delay(2000);
   setColor(0, 0, 255); / / Blue
   delay(2000);
   setColor(0, 255, 255); / / Aqua
   delay(2000);
}
void setColor(int red, int green, int blue)
{
   analogWrite(rledPin, red);
   analogWrite(gledPin, green);
   analogWrite(bledPin, blue);
}

As said above, the mosfet mechanism allows easy circuit tinkering. For example, you can add an LDR with the mosfet to switch the color wand only in darkness, without changing the source code. Or try to make a motion-triggered color wand.

Note: RGB LEDs are actually just 3 LEDs (red, green, blue) that share one lens, and have one of their 2 pins in common. This common pin is either the anode (positive), or the cathode (ground) of each LED. It is better to use a common cathode “diffused” RGB LED here because the diffused lens helps blend the colors (with the clear lens LED you can really see each color lit up separately, and it it hard to see the blended color) !

One Comments

Join the conversation!

Error! Please fill all fields.
Looking for the latest from TI?