loading

How to control an RGB LED with the arduino!

WHAT YOU NEED~

RGB LED

ARDUINO UNO, YUN, MEGA, PRO MINI, NANO, ECT

6 JUMPER WIRES

BREADBOARD

3 100K OHM RESISTOR

Step 1: The Led

The led legs are easy to understand the longest must be connected to the 5 volt pin of the arduino, and the shorter legs must go to a 100k ohm resistor connected in the following pattern~

RED- PIN 9

GREEN- PIN 10

BLUE- PIN 11

^^All connections are on the schematic above^^

Step 2: Coding

int redpin=9; //Pin 9 int greenpin=10; //Pin 10 int bluepin=11; //Pin 11 int var=0; int var1=0; void setup() { } void loop() { for(var=250;var<255;var++) { analogWrite(redpin,var); //RED analogWrite(greenpin,0); delay(500); analogWrite(redpin,0); //GREEN analogWrite(greenpin,var); delay(500); analogWrite(greenpin,0); //BLUE analogWrite(bluepin,var); delay(500); analogWrite(bluepin,0); delay(500); } for(var1=250;var1<255;var1++) { analogWrite(redpin,var1); //YELLOW analogWrite(greenpin,var1); delay(500); analogWrite(redpin,0); delay(500); analogWrite(greenpin,var1); //CYAN analogWrite(bluepin,var1); delay(500); analogWrite(greenpin,0); delay(500); analogWrite(bluepin,var1); //MAGENTA analogWrite(redpin,var1); delay(500); analogWrite(bluepin,0); delay(500); analogWrite(bluepin,var1); analogWrite(redpin,var1); analogWrite(greenpin,var1); } }

Step 3: Finished

Now that you have finished coding and wiring it is time to test if it doesn't work you can troubleshoot or comment!

THANKS FOR VEIWING!

FOR MORE~

Jacks How2s Website

<p>I copied this sketch to my Arduino and when I tried to verify it, I got an error message that said: &quot;exit status 1 Error compiling for board Arduino/Genuino Uno.&quot; Am I doing something wrong? If you will, please reply to my email address: usthom2000@yahoo.com</p>

About This Instructable

497views

14favorites

License:

Bio: Go to jackshow2s.weebly.com for more! Also Check Out Me On YouTube!
More by Jacks how2s:555 Timer Blink Circuit! 555 Timer Monstable Circuit! How to Make a Remote Fire Starter! 
Add instructable to: