loading
Easy Red, Green, Blue LED arduino for beginners. I will include some different codes and what each means.

Needed
-RGB LED
-Arduino Uno
-Jumper Wires
-9v batt. and cord

Step 1:

Step 2: RGB Pins

Connect v pin to yellow wire, green wire to g pin, blue wire to b pin, and red wire to r pin. The color doesn't matter as long as you assign that color of wire to Red, Green, Blue, or ground.

Step 3: Arduino Pins

Connect the yellow wire to ground, then green wire to pin 13, blue to pin 12, and red to pin 11

Step 4: Code

The code I have on it right now is just a simple blink sketch. It first turns flashes green for the setup, then in the loop flashes red and blue with a 200 delay. I will add more codes as I am able to make them.

Code:Blink

int green = 13; //declare/initialize led colors to their pins
int red = 12;

int blue = 11;

void setup() {

//initialize pins

pinMode(13, OUTPUT);

pinMode(12, OUTPUT);

pinMode(11, OUTPUT);

}

// the loop function runs over and over again forever

void loop() {

digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)

delay(200); // wait for a second

digitalWrite(13, LOW); // turn the LED off by making the voltage LOW

delay(200); // wait for a second

digitalWrite(12, HIGH); // turn the LED on (HIGH is the voltage level)

delay(200); // wait for a second

digitalWrite(12, LOW); // turn the LED off by making the voltage LOW

delay(200); // wait for a second

digitalWrite(11, HIGH); // turn the LED on (HIGH is the voltage level)

delay(200); // wait for a second

digitalWrite(11, LOW); // turn the LED off by making the voltage LOW

delay(200); // wait for a second }

Code:Blink Without Delay

int green = 13; //declare/initialize led colors to their pins
int red = 12;

int blue = 11;

void setup() {

//initialize pins

pinMode(13, OUTPUT);

pinMode(12, OUTPUT);

pinMode(11, OUTPUT);

}

// the loop function runs over and over again forever

void loop() {

digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)

delay(1000);

digitalWrite(13, LOW); // turn the LED off by making the voltage LOW

digitalWrite(12, HIGH); // turn the LED on (HIGH is the voltage level)

delay(100); // wait for a second

digitalWrite(12, LOW); // turn the LED off by making the voltage LOW

digitalWrite(11, HIGH); // turn the LED on (HIGH is the voltage level)

delay(200); // wait for a second

digitalWrite(11, LOW); // turn the LED off by making the voltage LOW

digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)

delay(1000); // wait for a second

digitalWrite(13, LOW); // turn the LED off by making the voltage LOW

digitalWrite(12, HIGH); // turn the LED on (HIGH is the voltage level)

delay(10); // wait for a second

digitalWrite(12, LOW); // turn the LED off by making the voltage LOW

digitalWrite(11, HIGH); // turn the LED on (HIGH is the voltage level)

delay(200); // wait for a second

digitalWrite(11, LOW); // turn the LED off by making the voltage LOW

digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)

delay(50); // wait for a second

digitalWrite(13, LOW); // turn the LED off by making the voltage LOW

digitalWrite(12, HIGH); // turn the LED on (HIGH is the voltage level)

delay(100); // wait for a second

digitalWrite(12, LOW); // turn the LED off by making the voltage LOW

digitalWrite(11, HIGH); // turn the LED on (HIGH is the voltage level)

delay(20); // wait for a second

digitalWrite(11, LOW); // turn the LED off by making the voltage LOW

digitalWrite(13, HIGH);

delay(1000);

digitalWrite(13, LOW);

digitalWrite(12, HIGH);

delay(1000);

digitalWrite(12, LOW);

digitalWrite(11, HIGH);

delay(2000);

digitalWrite(11, LOW);

digitalWrite(13, HIGH);

delay(1000);

digitalWrite(13, LOW);

digitalWrite(12, HIGH);

delay(1000);

digitalWrite(12, LOW);

digitalWrite(11, HIGH);

delay(2000);

digitalWrite(11, LOW); }

<p>You can change the order or timing by copying and pasting or changing the delay times.</p>
<p>int green = 13; //declare/initialize led colors to their pins</p><p>int red = 12;</p><p>int blue = 11;</p><p>void setup() {</p><p> //initialize pins</p><p>pinMode(13, OUTPUT); </p><p>pinMode(12, OUTPUT);</p><p>pinMode(11, OUTPUT);</p><p>}</p><p>// the loop function runs over and over again forever</p><p>void loop() {</p><p>digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)</p><p>delay(1000); // wait for a second</p><p>digitalWrite(13, LOW); // turn the LED off by making the voltage LOW</p><p>delay(1000); // wait for a second</p><p>digitalWrite(12, HIGH); // turn the LED on (HIGH is the voltage level)</p><p>delay(1000); // wait for a second</p><p>digitalWrite(12, LOW); // turn the LED off by making the voltage LOW</p><p>delay(1000); // wait for a second</p><p>digitalWrite(11, HIGH); // turn the LED on (HIGH is the voltage level)</p><p>delay(1000); // wait for a second</p><p>digitalWrite(11, LOW); // turn the LED off by making the voltage LOW</p><p>delay(1000); // wait for a second</p><p>}</p>
<p>void setup() {</p><p> // initialize digital pin 13 as an output.</p><p> pinMode(13, OUTPUT);</p><p>}</p><p>// the loop function runs over and over again forever</p><p>void loop() {</p><p> digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)</p><p> delay(1000); // wait for a second</p><p> digitalWrite(13, LOW); // turn the LED off by making the voltage LOW</p><p> delay(1000); // wait for a second</p><p>}</p>
I cant upload a sketch or video right now, but will as soon as I can.

About This Instructable

756views

16favorites

License:

More by Jaxton Maez:Arduino flashing LED lamp Easy RGB LED Mini Pencil 
Add instructable to: