Game Countdown Timer-LED Lights
by niniwu1207 in Circuits > Arduino
323 Views, 0 Favorites, 0 Comments
Game Countdown Timer-LED Lights
Idea from: https://www.instructables.com/Flowing-LED-Lights-W...
About: I want to make this so that the players or contestants in a game can look at the light bulbs that is counting down and know that when the light in the last light bulb is out, it means the game has started.
Changes made: I changed the last "delay" time into 1000. The purpose is that then it can be a countdown timer for any contests.
Altered Code: https://create.arduino.cc/editor/niniwu/af9a36c5-3...
Video Link:
Downloads
Prepare for Materials
- Arduino Uno board * 1
- USB cable * 1
- Resistor (110Ω) * 8
- LED * 8
- Potentiometer * 1
- Breadboard * 1
- Jumper wires
Build the Circuit
(This picture is from the website: https://www.instructables.com/Flowing-LED-Lights-With-Arduino-Uno-R3/)
- Build the circuit based on the picture provided:
1. Plug 8 wires into D2-D9, and plug the other edge of the wires into the breadboard
2. Plug one edge of the 8 resisters on the same line as the previous wires, the other edge of the resisters should be on the same line as well.
3. Plug one edge of the other 8 wires beside each resister. and the other edge should be plugged into the negative column.
4. Plug the longer leg of the LED light beside the resister.
5. Plug the shorter leg of the LED light beside the wires mentioned in step 3.
Code
Copy the code onto Arduino:
const
int lowestPin = 2;//the lowest one attach to
const int highestPin = 9;//the highest one attach to
/**************************************/
void setup()
{
//set pins 2 through 9 as output
for(int thisPin = lowestPin;thisPin <= highestPin;thisPin++)
{
pinMode(thisPin,OUTPUT); //initialize
}
}
/****************************************/
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
delay(100);//wait for 100 ms
}
//fade from the highest to the lowest
for(int thisPin = highestPin;thisPin>=lowestPin;thisPin--)
{
digitalWrite(thisPin,LOW);//turn this led
delay(100);//wait for 100 ms
}
for(int thisPin = highestPin;thisPin>=lowestPin;thisPin--)
{
digitalWrite(thisPin,HIGH);//turn this led on
delay(100);//wait for 100 ms
}
for(int thisPin = lowestPin;thisPin <= highestPin;thisPin++)
{
digitalWrite(thisPin,LOW);//turn this led
delay(1000);//wait for 100 ms
}
}
Upload!!
- press the upload button in Arduino, then your game countdown timer will appear!