Decorative (Night) Light!!! (RGB LEDs)

by tseng916 in Workshop > Electric Vehicles

153 Views, 1 Favorites, 0 Comments

Decorative (Night) Light!!! (RGB LEDs)

finish (product)

This is a color changing decorative (Night) light, which uses RGB LEDs with Arduino. RGB LEDs contain 3 colors that can be mix to change into different color, such as blue and red equals to purple... That's why the light cup above changes color in the video. RGB LEDs with Arduino can be used as an indicator of certain sensor outputs or even cool light shows with enough RGB LEDs. Making this decorative (Night) light will be fun and useful for you! Hope you enjoy! ;)

My reference link for this project is from: https://www.instructables.com/Using-RGB-LEDs-With...

Supplies

for making the light:

1. cardboards

2. Scissor or knife

3. tape or glue

4. paper cup

for wiring:

1. Arduino 101 or Arduino Uno

2. Breadboard

3. RGB LED

4. 3 100Ω resistor

5. Jumper Wires (male to male)

Prepare Materials for Wiring:

截圖 2021-04-12 下午5.48.24.png
截圖 2021-04-12 下午5.49.05.png
截圖 2021-04-12 下午5.49.53.png
截圖 2021-04-12 下午5.50.19.png
截圖 2021-04-12 下午5.50.45.png

1. Arduino 101 or Arduino Uno

2. Breadboard

3. RGB LED

4. 100Ω resistor x3

5. Jumper Wires (male to male and male to female)

Start Wiring (connect the Arduino Power to the Breadboard):

截圖 2021-04-12 下午5.56.37.png
截圖 2021-04-12 下午5.56.47.png

To connect the Arduino power to the breadboard, take one male to male wire, connect it on 3.3V pin of the Arduino power to the red power rail in the breadboard, which is the positive power on the bus strip.

Next, take one more male to male wire and connect it on the GND pin of the Arduino to the black or blue rail in the breadboard. Which is the negative power on the breadboard's bus strip.

Finish Wiring (Circuitry/ Wire the RGB LED on the Breadboard to Connect to the Arduino):

截圖 2021-04-12 下午6.13.01.png
截圖 2021-04-12 下午6.13.26.png
截圖 2021-04-12 下午6.13.36.png
截圖 2021-04-12 下午6.13.45.png

Connect the RGB lights on the ground rail in the breadboard using male to female wire.

Then connect the longest leg with negative power, and connect other legs with 100Ω resistors.

Each of these legs will be connected as a digital output of the Arduino. Connect the leg that's closest to the ground pin 5. Connect the rest of these pins to pins 6 and 9 in sequential order upwards.

Coding and Testing

截圖 2021-04-12 下午7.58.14.png
testing
截圖 2021-04-13 下午1.47.29.png
截圖 2021-04-13 下午1.47.40.png
截圖 2021-04-27 下午4.05.22.png

Code: https://create.arduino.cc/editor/zoetseng/0cdc509...

改良delay, 1000換到500,因為燈光轉換的速度過慢,沒辦法清楚的看出燈光的轉變。

full code:

//create variables for pin numbers. We are making them constants here, because they //never change.

const int RED_PIN = 5; const int GREEN_PIN = 6; const int BLUE_PIN = 9;

// How fast we plan to cycle through colors in milliseconds int DISPLAY_TIME = 10;

void setup() { //set the three pin variables as outputs pinMode(RED_PIN, OUTPUT); pinMode(GREEN_PIN, OUTPUT); pinMode(BLUE_PIN, OUTPUT); }

void loop() {

red();

delay(500);

yellow();

delay(500);

green();

delay(500);

cyan();

delay(500);

blue();

delay(500);

purple();

delay(500);

off();

delay(500);

}

void blue (){ // Blue (turn just the blue LED on): digitalWrite(RED_PIN, LOW); digitalWrite(GREEN_PIN, LOW); digitalWrite(BLUE_PIN, HIGH);

}

void yellow(){ // Yellow (turn red and green on): digitalWrite(RED_PIN, HIGH); digitalWrite(GREEN_PIN, HIGH); digitalWrite(BLUE_PIN, LOW);

}

void off(){

// Off (all LEDs off): digitalWrite(RED_PIN, LOW); digitalWrite(GREEN_PIN, LOW); digitalWrite(BLUE_PIN, LOW);

}

void green(){ // Green (turn just the green LED on): digitalWrite(RED_PIN, LOW); digitalWrite(GREEN_PIN, HIGH); digitalWrite(BLUE_PIN, LOW); }

void red (){ // Red (turn just the red LED on): digitalWrite(RED_PIN, HIGH); digitalWrite(GREEN_PIN, LOW); digitalWrite(BLUE_PIN, LOW); }

void cyan() { // Cyan (turn green and blue on): digitalWrite(RED_PIN, LOW); digitalWrite(GREEN_PIN, HIGH); digitalWrite(BLUE_PIN, HIGH); }

void purple(){ // Purple (turn red and blue on): digitalWrite(RED_PIN, HIGH); digitalWrite(GREEN_PIN, LOW); digitalWrite(BLUE_PIN, HIGH); }

void white(){ // White (turn all the LEDs on): digitalWrite(RED_PIN, HIGH); digitalWrite(GREEN_PIN, HIGH); digitalWrite(BLUE_PIN, HIGH); }

Making the Decorative (Night) Light

截圖 2021-04-12 下午8.07.16.png
截圖 2021-04-12 下午8.07.28.png
截圖 2021-04-12 下午8.07.46.png

prepare materials:

1. cardboards

2. Scissor or knife

3. tape or glue

4. paper cup

cut the cardboard into pieces that can cover the breadboard and the wires, like the image above. Then stick the cardboard together and stamp a hole on the top of the cover. Which the RGB LED can go through. Lastly stick the paper cup on the cardboard box.

Finish!

finish (product)