HOW TO CONTROL AN RGB LED WITH ARDUINO! 2 MINUTES

by Jacks how2s in Circuits > Arduino

873 Views, 14 Favorites, 0 Comments

HOW TO CONTROL AN RGB LED WITH ARDUINO! 2 MINUTES

IMG_3906.JPG
IMG_3907.JPG

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

The Led

IMG_3910.JPG
IMG_3905.JPG
IMG_3908.JPG
IMG_3912.JPG
IMG_3913.JPG
IMG_3915.JPG

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^^

Coding

IMG_3917.JPG
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); } }

Finished

IMG_3919.JPG

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