RGB LED Lamp
This is a special lamp that helps you sleep well. I use the RGB LED to make this lamp, it's elegant if you add a cover.
Supplies
1x Arduino Leonardo
5x Wires
4x Clip wires
1x RGB LED
1x Paper
1x 100ohm resistor
Code
The link for full codes: Arduino CC
//RGB LED lamp //The color of LED changes in the order of red, orange, yellow, green, blue, dark blue, and then purple. //The RGB LED is controlled by the color of red, green, and blue //Pin 7 controls the brightness of the red //Pin 6 controls the brightness of the green //Pin 5 controls the brightness of the blue void setup(){ // put your setup code here, to run once: } void loop(){ // Main code analogWrite(7 , 255); //改 analogWrite(6 , 0); //改 analogWrite(5 , 0); //改 delay( 1000 ); // waits a few milliseconds //Red analogWrite(7 , 255); //改 analogWrite(6 , 120); //改 analogWrite(5 , 0); //改 delay( 1000 ); // waits a few milliseconds //Orange analogWrite(7 , 255);//改 analogWrite(6 , 255); //改 analogWrite(5 , 0); //改 delay( 1000 ); // waits a few milliseconds //Yellow analogWrite(7 , 0); //改 analogWrite(6 , 255); //改 analogWrite(5 , 0); //改 delay( 1000 ); // waits a few milliseconds //Green analogWrite(7 , 0); //改 analogWrite(6 , 255); //改 analogWrite(5 , 255); //改 delay( 1000 ); // waits a few milliseconds //Blue analogWrite(7 , 0); //改 analogWrite(6 , 0); //改 analogWrite(5 , 255); //改 delay( 1000 ); // waits a few milliseconds //Dark Blue analogWrite(7 , 130); //改 analogWrite(6 , 0); //改 analogWrite(5 , 255); //改 delay( 1000 ); // waits a few milliseconds //Purple }
Explain
RGB LED is controlled by a negative polarity and three kinds of light: Red, Green, and Blue. These three colors are the primary colors of light. Different brightness for each color combined can make almost all kinds of color. I choose the colors of the rainbow: red, orange, yellow, green, blue, dark blue, and violet to be the colors of my lamp.
Building Up Arduino
Build up the circuit like the image above.
- Three wires connect from D5, D6, and D7 to the RGB LED.
- A wire connects from GND to LED's negative polarity
- 4 clip wires connect to the RGB LED
- Upload the codes from Arduino app
- Make a paper shade cover on it
Here is a link for how to use a paper to make lamp cover:
https://www.youtube.com/watch?v=DCelEdIow2c
After all of that, you are finish!
Congrats!
Source: LED blinking