Introduction: Arduino Start Signal
In this project, you'll learn how to make a simple start signal, complete with three signal lights and a starting chime, using Arduino. The starting signal is great to use for games with friends, or if you want to teach kids and students about the basics of circuits!
Supplies
- Jumper Wire x8
- 10 Kiloohm Resistor x4
- 220 Ohm Resistor x1
- Red, Yellow, and Green LED
- Button x1
- Piezo x1
- Arduino Uno
- Breadboard
Step 1: Building the Circuit
- Connect 5V power and ground from the Arduino to the the Breadboard using jumper wires.
- Add in the button, using the 10 kiloohm resistor and connecting it to digital pin 8. Don't forget to also connect the button to power!
- Add in the three LEDs, using the 220 ohm resistors and connecting them to digital pin 5,6, and 7.
- Finally, add in the piezo again using a 220 ohm resistor and connecting it to digital pin 4.
Step 2: The Code
- The following code is to be written using Arduino Editor.
- Read the comments in the code to understand what each section is doing.
const int buttonPin = 8; const int ledPin = 7; const int led2Pin = 6; const int led3Pin = 5; const int buzzerPin = 4; int buttonState = 0; //defining what digital pin each piece of hardware is connected to, and assigning it a name. //If you change the positioning of anything on the breadboard, make sure to change it here to. void setup(){ pinMode(ledPin, OUTPUT); pinMode(led2Pin, OUTPUT); pinMode(led3Pin, OUTPUT); pinMode(buzzerPin, OUTPUT); pinMode(buttonPin, INPUT); //defining the lights and buzzer as outputs, and the button as an input } void loop(){ buttonState = digitalRead(buttonPin); if(buttonState == HIGH){ digitalWrite(ledPin, HIGH); delay(1250); digitalWrite(led2Pin, HIGH); delay(1250); digitalWrite(led3Pin, HIGH); tone(buzzerPin, 1000); delay(1000); noTone(buzzerPin); //this section dictates what happens when the button is pressed. The first light will turn on, with a 1.25 second break between each. //Once the third light turns on, the buzzer will buzz for 1 second before stopping. If you want to change the time between the lights turning on, change the number in the delay() brackets. } else { digitalWrite(ledPin, LOW); digitalWrite(led2Pin, LOW); digitalWrite(led3Pin, LOW); noTone(buzzerPin); //this section dictates what will happen when the button is NOT pressed. It makes sure that the LEDs and buzzer all off when the button isn't pressed. } }
Step 3: Upload Code to Arduino
- Use a USB cable to upload the code from the Arduino editor to the Arduino.
- Press the button to see the start signal go!