Traffic Light Simulate System With LED Light Timer 🚦🚘🚶🏻♂️🚸
by jacqueline wang in Circuits > Arduino
359 Views, 0 Favorites, 0 Comments
Traffic Light Simulate System With LED Light Timer 🚦🚘🚶🏻♂️🚸
About this project:
This project is making a traffic light simulation system with an LED blinking technique. This project's main goal is to teach young children how to recognize when they can pass the street by looking at the traffic light. There are two sets of traffic lights on the breadboard, the left side is the traffic light of cars, the right side is the pedestrian traffic lights. When the light of cars turns red, the light of pedestrians will turn green. When the light of cars turns green, the light of pedestrians will turn red. Moreover, there is a yellow light on the traffic light of cars, it is for letting people know the traffic light of cars and pedestrians is turning either red or green. In addition, there are four white LED lights that simulate the countdown timer you will usually see when you are crossing the road. The four white LED lights shine at the same time as the yellow LED light. As the four LED lights blink after five times, it means that the traffic light of cars and pedestrians is turning either red or green!!!
Parts & Materials Needed 🧩
- Nine LEDs (green x2 yellow x1 red x2 white x4)
- Jumper wires x15
- Breadboard x1
- Arduino x1
Program the Arduino (coding)
Code Link: https://create.arduino.cc/editor/jacquelinewang911...
Paste the following code into the Arduino software and upload it to the Arduino
int led = 13;
int led2 = 12;
int led3 = 11;
int led4 = 10;
int led5 = 9;
int led6 = 8;
int led7 = 7;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
pinMode(led6, OUTPUT);
pinMode(led7, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH);// turn the LED on (HIGH is the voltage level)
digitalWrite(led5, HIGH);
delay(10000); // wait for 10 seconds
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
digitalWrite(led5, LOW);
delay(100);
{digitalWrite(led2, HIGH);
digitalWrite(led6, HIGH);
digitalWrite(led7, HIGH);
delay(1000);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
delay(1000);
digitalWrite(led6, HIGH);
digitalWrite(led7, HIGH);
delay(1000);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
delay(1000);
digitalWrite(led6, HIGH);
digitalWrite(led7, HIGH);
delay(1000);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
delay(1000);
digitalWrite(led6, HIGH);
digitalWrite(led7, HIGH);
delay(1000);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
delay(1000);
digitalWrite(led6, HIGH);
digitalWrite(led7, HIGH);
delay(1000);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
delay(10);
digitalWrite(led2, LOW);
delay(100);}
{digitalWrite(led3, HIGH);
digitalWrite(led4, HIGH);
delay(10000);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
delay(100);}// wait for a second
{digitalWrite(led2, HIGH);
digitalWrite(led6, HIGH);
digitalWrite(led7, HIGH);
delay(1000);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
delay(1000);
digitalWrite(led6, HIGH);
digitalWrite(led7, HIGH);
delay(1000);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
delay(1000);
digitalWrite(led6, HIGH);
digitalWrite(led7, HIGH);
delay(1000);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
delay(1000);
digitalWrite(led6, HIGH);
digitalWrite(led7, HIGH);
delay(1000);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
delay(1000);
digitalWrite(led6, HIGH);
digitalWrite(led7, HIGH);
delay(1000);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
delay(10);
digitalWrite(led2, LOW);
delay(100);}// wait for a second
}
Connecting GND
First, connect a jumper wire from GND to the negative rail on the breadboard.
Connecting the LEDs
Then plug in the other jumper wires like this:
1. plug a wire from 13 on the Arduino to the left side of the RED LED
2. plug a wire from the negative rail to the right side of the RED LED
3. plug a wire from 12 on the Arduino to the left side of the YELLOW LED
4. plug a wire from the negative rail to the right side of the YELLOW LED
5. plug a wire from 11 on the Arduino to the left side of the GREEN LED
6. plug a wire from the negative rail to the right side of the GREEN LED
7. plug a wire from 10 on the Arduino to the left side of the RED LED (pedestrian light)
8. plug a wire from the negative rail to the right side of the RED LED (pedestrian light)
9. plug a wire from 9 on the Arduino to the left side of the GREEN LED (pedestrian light)
10. plug a wire from the negative rail to the right side of the GREEN LED (pedestrian light)
11. plug a wire from 8 on the Arduino to the left side of the WHITE LED (timer)
12. plug a wire from the negative rail to the right side of the WHITE LED (timer)
13. plug a wire from 7 on the Arduino to the left side of the WHITE LED (timer)
14. plug a wire from the negative rail to the right side of the WHITE LED (timer)