Arduino RGB Lights (With an on and Off Knob)
by AnderHarden13 in Circuits > Arduino
190 Views, 1 Favorites, 0 Comments
Arduino RGB Lights (With an on and Off Knob)
In the modern days, esports is popular for professional gamers, they are willing to show their talents and earn the grand prize. In order to do that, they would need both keyboards and mouses, the two essential gadgets that are required to play video games. Usually, the decorations on the gadgets would be both fancy and colorful for the gamers while they are showing off their talented gaming skills. RGB Lights are used for almost every gamer in the world, the colorful lights and the cool patterns attract customers to buy them. What makes the product interesting for the users is the ability to produce vibrant colors, and excellent lightness. The Arduino RGB Lights create the same effects as the real one! There are 5 total effects of this project and each effect is suitable for the gaming atmosphere! The idea was inspired by Arduino LED Chaser ( With 5 Effects )
Link: https://www.instructables.com/Arduino-LED-Chaser-W...
In the project, I changed it by adding a button to start the effects for every loop and changing the placement of different LED lights into a certain order instead of the original red, green, and blue. In order to improve the disadvantage of this project since the LED lights will continuously light up, it may affect the users' eyesight since they usually use the RGB Lights Product in much darker places. This improvement on the machine will be used to decrease the difficulties the users may face while using the product and will be applied to those who face eye diseases such as Dry Eye Syndrome or Conjunctivitis to secure their eyesight. On the other hand, it could be conveniently used for those students who are too afraid to let their parents know that they have such a cool product, when the parents come into their room, they could turn off the light source in an instant to keep them from taking the RGB Lights Machine.
Preparing Materials
-
Arduino Leonardo x1
-
Arduino Cable x1
-
Breadboard x1
-
LED Lights x9 ( 2 Red, 2 Orange, 3 Green, 2 Blue)
-
Jumper Cables x16
-
Jumper Cables with one end x3
-
Interchangeable Resistor x1
-
Button x1
-
Resistor x1
Colored Papers x4
Foam x1
Plastic Cover x1
Cardboard Box x1
Marker x1
Connecting the Circuits
- First, connect the positive and negative sides (two ends) of the breadboard using two jumper cables. Then connect 5V to GND and GND to the negative rail; connect all LED negative terminal on the negative port of the breadboard.
- Add the LED lights according to the circuit diagram. The order of LED lights' placement is red, orange, orange, green, green, green, blue, blue, then red ( The color placement can be optional).
- Connect the jumper cables on the positive side of each LED's
- Connect 9 jumper cables to the positive side of each LED on the second terminal, the other end to digital pins 1-9 on the Arduino.
- Use a jumper cable to connect the positive side of the Arduino to the first terminal, then connect the button to the breadboard.
- Place one end of the resistor within the same row as the button is; use a jumper cable to connect the other end of the resistor with the negative side of Arduino.
- Connect the interchangeable resistor with three cables, the left one on the positive socket, the right one on the negative socket, and the middle one on the A0 pin socket.
- The interchangeable resistor doesn't connect with the breadboard, since the electric flow can't go sideways.
- The circuit connection is all done.
- Place the Arduino board into a paper box, covering the box with a thin piece of the plastic cover.
- Decorate the box with a few colored papers (optional)
- Cut holes with a utility knife to create space for placing the button, the interchangeable resistor, and the cable connecting to the computer.
- Use the foam, some colored papers, and a marker to label the result in turning the knob (turn left= off, turn right= on)
Arduino Code
Copy this code and upload it onto the Arduino software
Finish the steps above then upload it onto your own Arduino Leonardo
Or download the file below
void setup()
{ pinMode(1,OUTPUT); pinMode(2,OUTPUT); pinMode(3,OUTPUT); pinMode(4,OUTPUT); pinMode(5,OUTPUT); pinMode(6,OUTPUT); pinMode(7,OUTPUT); pinMode(8,OUTPUT); pinMode(9,OUTPUT); pinMode(10 , INPUT); } 9個LED燈
void loop() { analogWrite(1 , ( analogRead( A0 ) / 4 )); //analogWrite values from 0 to 255 analogWrite(2 , ( analogRead( A0 ) / 4 )); //analogWrite values from 0 to 255 analogWrite(3 , ( analogRead( A0 ) / 4 )); //analogWrite values from 0 to 255 analogWrite(4 , ( analogRead( A0 ) / 4 )); //analogWrite values from 0 to 255 analogWrite(5 , ( analogRead( A0 ) / 4 )); //analogWrite values from 0 to 255 analogWrite(6 , ( analogRead( A0 ) / 4 )); //analogWrite values from 0 to 255 analogWrite(7 , ( analogRead( A0 ) / 4 )); //analogWrite values from 0 to 255 analogWrite(8 , ( analogRead( A0 ) / 4 )); //analogWrite values from 0 to 255 analogWrite(9 , ( analogRead( A0 ) / 4 )); //analogWrite values from 0 to 255 int i; 旋鈕控制LED燈光
// 1st pattern repeat 1 times if (digitalRead( 10 )) { for(i=1; i<=10; i++) { digitalWrite(i,HIGH); delay(50); digitalWrite(i,LOW); delay(50); } for(i=10; i>=1; i--) { digitalWrite(i,HIGH); delay(50); digitalWrite(i,LOW); delay(50); } delay(1000);
//2nd pattern repeat 1 times
for(i=1; i<=10 ; i++) { digitalWrite(i,HIGH); delay(50); } for(i=1; i<=10 ; i++) { digitalWrite(i,LOW); delay(50); } for(i=10; i>=1 ; i--) { digitalWrite(i,HIGH); delay(50); } for(i=10; i>=1 ; i--) { digitalWrite(i,LOW); delay(50); } delay(1000);
//3rd pattern repeat 1 times
for(i=1; i<=10 ; i++) { digitalWrite(i,HIGH); delay(50); } for(i=11; i>=1 ; i--) { digitalWrite(i,LOW); delay(50); } for(i=10; i>=1 ; i--) { digitalWrite(i,HIGH); delay(50); } for(i=1; i<=10 ; i++) { digitalWrite(i,LOW); delay(50); } delay(1000);
//4th pattern repeat 1 times
for(i=1; i<=5 ; i++) { digitalWrite(i,HIGH); digitalWrite(11-i,HIGH); delay(100); } for(i=1; i<=5 ; i++) { digitalWrite(i,LOW); digitalWrite(11-i,LOW); delay(100); } delay(100); for(i=1; i<=5 ; i++) { digitalWrite(i,HIGH); digitalWrite(11-i,HIGH); delay(100); } for(i=5; i>=1 ; i--) { digitalWrite(i,LOW); digitalWrite(11-i,LOW); delay(100); } delay(1000); //5th pattern rpeat 1 time for(i=1 ; i<=3 ; i++) { digitalWrite(i,HIGH); digitalWrite(i+3,HIGH); digitalWrite(i+6,HIGH); delay(500/i); } delay(500); for(i=1 ; i<=3 ; i++) { digitalWrite(i,LOW); digitalWrite(i+3,LOW); digitalWrite(i+6,LOW); delay(500/i); }
delay(1000); }
}
Downloads
Testing
You can repeat all five of the effects every time you press the button
You can turn off the lights using the knob
You can also decorate your own RGB Lights to make it more creative!!!
I used colored papers onto the RGB Lights box to decorate the product, but feel free to be creative in designing your own creation!!!