L.O.A.S.H’s Guide to (nearly) Everything: Arduino Color Lamp Mixer!

Quote of awesomeness: “Is not about creating an object. It is about creating a perspective.” ~ Albert Paley

Level of hardness: intermediate (You can do this!)

Heyyy!!!! Here’s another Arduino project for you!

For this project, you will need the following:

  • 1x Arduino UNO Board
  • 1x USB Cable Type A/B
  • 1x Breadboard
  • 1x RGB LED 
  • 3x 220-Ohm Resistor
  • 3x 10k-Ohm Resistor
  • 3x Photoresistors
  • 13x Jumper Wires

 

Step 1:

0-02-01-25a0a6f9debabdd212fbc3c05acd2fcf5f1c439705c879adf26fea2d27db35df_full.jpg

The first step is two connect your breadboard to your Arduino and it should look something like the photo above. Then, add your RGB LED to your breadboard. 

Step 2:

0-02-01-ce8d12da04188f7a9054ea5aa04a72e5ac576232bc208167812c08ec3ba18cfe_full

 

Next, you need to grab another wire and connect the other positive lane of the breadboard to the negative lane on the other side of the breadboard.

 

Step 3:

0-02-01-9bde85f3c5437a50c6a476f15138e6c5858ce46a700364835db6ee8e53447d2f_full

In this step, we will be placing the three 220-Ohm Resistors to three of the legs of the RGB LED. You will only be placing the resistors on the R, G and B of the RGB LED, this will leave you with one leg unconnected.

 

Step 4:

0-02-01-dbc63a13ab6f50466eb8dd3465af30d65b8f5e7967920a87645ee225ffaa44ea_full.jpg

For this step, you will be needing four wires. Remember I told you that you were left with one leg of the RGB LED which isn’t connected? Well, it’s time to connect it now! Place one end of the wire to the remaining leg of the RGB LED then place the other end to the negative lane of the board. In the photo, the wire which I used for this connection is white.

0-02-01-61ac8f02b55daa224f1962b3e828047ead0580414fcee62ded86ee5ad453523a_full.jpg

With the other three wires, connect it to each of the 220-ohm resistors. Then, connect the other end of the wires to the Arduino 9, 19, and 11.

 

Step 5:

0-02-01-9f2cb7be6b6ebbcc06aaf7b34dfd409e332e34965665efa0386c1a48cf6d16fb_full.jpg

Let’s place the photo-resistors on the breadboard so that they cross the center divide from one side to the other. 

 

Step 6:

0-02-01-c45f2f455156cfbfb4d1aee3c77926f4c5d55503f0796170018956fc0281a57a_full.jpg

Now, connect the 10k-Ohm resistors to one side of the photo-resistors and the other side to the negative lane of the breadboard.

 

Step 7:

0-02-01-3e1c74c9aa8f84a2158daa0ca5b528a6e2785236e0f532f18c1820533a1aa4a9_full.jpg

Taking three other wires, connect it between the photo-resistor and the 10k-Ohm resistor then connect the other end to the Analog In pins 0, 1, and 2 on the Arduino.

 

Step 8:

0-02-01-b946dc989126c65408412e7a570d06c10c28d9cfba450fc3cdc3bf12acca7b91_full.jpg

Going on the other side of the photo-resistor, connect each leg to the positive lane of the Arduino with three wires.

0-02-01-1733d59664a66910bba653033a94e1427937448a2a20dee06bab915fa06fac0f_full.jpg

Your result should look something like this!

 

Step 9:

This is the final step! Connect your Arduino to your computer, fire up your Arduino and copy paste in the following code:

const int greenLEDPin = 9;
const int redLEDPin = 11;
const int blueLEDPin = 10;

const int redSensorPin = A0;
const int greenSensorPin = A1;
const int blueSensorPin = A2;

int redValue = 0;
int greenValue = 0;
int blueValue = 0;

int redSensorValue = 0;
int greenSensorValue = 0;
int blueSensorValue = 0;

void setup() {
Serial.begin(9600);

pinMode(greenLEDPin, OUTPUT);
pinMode(redLEDPin, OUTPUT);
pinMode(blueLEDPin, OUTPUT);

}

void loop() {
redSensorValue = analogRead(redSensorPin);
delay(5);
greenSensorValue = analogRead(greenSensorPin);
delay(5);
blueSensorValue = analogRead(blueSensorPin);

Serial.print(“Raw Sensor Value \t Red: “);
Serial.print(redSensorValue);
Serial.print(“\t Green: “);
Serial.print(greenSensorValue);
Serial.print(“\t Blue: “);
Serial.print(blueSensorValue);

redValue = redSensorValue/4;
greenValue = greenSensorValue/4;
blueValue = blueSensorValue/4;

Serial.print(“Mapped Sensor Values \t Red: “);
Serial.print(redValue);
Serial.print(“\t Green: “);
Serial.print(greenValue);
Serial.print(“\t Blue: “);
Serial.println(blueValue);

analogWrite(redLEDPin, redValue);
analogWrite(greenLEDPin, greenValue);
analogWrite(blueLEDPin, blueValue);
}

 

Then watch as your RGD LED comes to life! It should change, mix and fade in different colours as the light around it changes, too! Awesome, right?? Yeah, it totally is.

Yours truly,

L.O.A.S.H

 


 © Elizabeth Anne Villoria