Introduction: HOW TO CONTROL AN RGB LED WITH ARDUINO! 2 MINUTES

Picture of HOW TO CONTROL AN RGB LED WITH ARDUINO! 2 MINUTES

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

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

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

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

Comments

WhittlinThom (author)2016-09-11

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

About This Instructable

533views

14favorites

License:

Bio: Go to jackshow2s.weebly.com for more! Also Check Out Me On YouTube!
More by Jacks how2s:How to Make An Automatic Coffee Pod Dispenser With ArduinoHow to Make a 555 Timer Blink Circuit on a PCB!DIY 3D Printed Fidget Spinner
Add instructable to: