Introduction: RGB LED Smooth Color Transition Using Arduino UNO

About: DIY Arduino tutorials

If you are searching through the internet to find a sketch for arduino uno and/or to find which electrical components you need, then don't worry you've almost got it. Here is what you need to do...

Step 1: Components

1. Arduino Uno/other boards can work too but check which pins provide PWM

2. Three 220 ohm resistors (if you don't have 220 ohm resitors you can use resistors that are in range of 55 ohms - 220 ohms)

3. 4 jumper wires

4. at least one RGB 5mm LED

5. one breadboard

Step 2: Connecting Components

It doesn't matter which breadboard you use.

1. Connect the cathode(longest pin) to ground

2. Connect other 3 wires to pins 11, 10 and 9 (colors of the wires in my schematic represent the color of the LED lights)

Step 3: Code - Feel Free to Copy (please, Don't Forget to Like Share and Subscribe)

Now copy and upload the code into your arduino and enjoy your DIY RGB LED lights:

/* This sketch is made by zimmermannard */

const int red = 11; /* connected to PWM pin 11 */

const int green = 10; /* connected to PWM pin 10 */

const int blue = 9; /* connected to PWM pin 9 */

int r = 255; /* red led value is temporally 255 and it will be the first led to light up */

int b; /* blue led value is temporally 0 */

int g; /* green led value is temporally 0 */

int t = 1000; /* "t" (time) 1000 milliseconds, feel free to change it */

void setup() {/* no setup */}

void loop() {

for (/* no initialization */; r>=0, b<255; b++, r--) /*red -> blue*/

{

analogWrite(red, r);

analogWrite(blue, b);

delay(t);

}

for (/* no initialization */; b>=0, g<255; g++, b--) /*blue -> green*/

{

analogWrite(blue, b);

analogWrite(green, g);

delay(t);

}

for (/* no initialization */; g>=0, r<255; r++, g--) /*green -> red*/

{

analogWrite(red, r);

analogWrite(green, g);

delay(t);

}

}