Flowing LED Lights With Arduino Leonardo
by ulandachen0509 in Craft > Digital Graphics
51 Views, 0 Favorites, 0 Comments
Flowing LED Lights With Arduino Leonardo
Signs often use colors and lights to grab people's attention, for example, traffic lights. My device presents a series of LED lights that light up and dim one after another. It performs a function of the commercial sign to grab the audience's attention as the lights quickly flash.
This work is inspired by the work: https://www.instructables.com/Flowing-LED-Lights-...
Improved Features
- Delay Time: The delay time was decreased to 50ms as faster light changes better grab people's attention,
- Appearance: A box was added to cover up the wires and the board for an attractive appearance. The box is colored in sections the same as the colors of the light to grab attention.
- Color of LED: The colors of the lights was changed into red, yellow, green, and blue.
Materials
Arduino Leonardo * 1
Breadboard * 1
Resistor (as shown in the photo) * 8
LED * 8 (red, yellow, green, blue each * 2)
Jumper wires
Circuit
Connect the circuits according to the pictures shown above:
- LED: long leg to D pins, short leg to resistors
- Resistors to negative (to GND)
*Note: D pins can be adjusted, select whichever pin you want.
Code
/**************************************/ const int lowestPin = 5;//the lowest one attach to const int highestPin = 13;//the highest one attach to /**************************************/ void setup() { //set pins 5 through 13 as output for(int thisPin = lowestPin;thisPin <= highestPin;thisPin++) { pinMode(thisPin,OUTPUT); //initialize thisPin as an output } } /****************************************/ void loop() { //iterate over the pins //turn the led on from lowest to the highest for(int thisPin = lowestPin;thisPin <= highestPin;thisPin++) { digitalWrite(thisPin,HIGH);//turn this led on delay(50);//改wait for 50 ms } //fade from the highest to the lowest for(int thisPin = highestPin;thisPin>=lowestPin;thisPin--) { digitalWrite(thisPin,LOW);//turn this led off delay(50);//改wait for 50 ms } for(int thisPin = highestPin;thisPin>=lowestPin;thisPin--) { digitalWrite(thisPin,HIGH);//turn this led on delay(50);//改wait for 50 ms } for(int thisPin = lowestPin;thisPin <= highestPin;thisPin++) { digitalWrite(thisPin,LOW);//turn this led off delay(50);//改wait for 50 ms } }
Procedure
Step 1: Connect the circuit
Step 2: Copy the code given
Step 3: Make the box
Step 4: Upload the code and let them shine!