Arduino LED Traffic Light

by connie822 in Circuits > Arduino

132 Views, 0 Favorites, 0 Comments

Arduino LED Traffic Light

截圖 2021-04-18 上午12.46.59.png

For this project:

This project is a traffic light stimulation system with LED techniques. The purpose of this project is to promote the importance of looking at the traffic lights while crossing a street.

I got this idea from: https://www.instructables.com/Arduino-LED-Traffic...

How does the idea work?
The original idea is a simple LED blinking system, including red, yellow, and green lights, where red represents “stop”, yellow represents “wait and look around”, green represents “go”. Each of the lights blinks every four to five seconds and blinks at a certain rate or pattern. However, I improved this idea to blinking every two seconds and different patterns with the same lighting color remaining.

Changes: (By additional coding)
-Decrease blinking rate to an average of two seconds/lighting color

-Change the pattern rate between yellow and green lights

Preparing Materials

截圖 2021-04-18 上午1.44.55.png

-Arduino x1

-Breadboard x1

-Jumper wires x4

-220-ohm Resistor x3 (Red, Black, Red, Brown)

-Red LED x1

-Yellow LED x1

-Green LED x1

-USB Cable x1

-Transparent Plastic Cardboard x1

-Scissors x1

-Tape x1

-Marker x1

Connecting the GND

截圖 2021-04-18 上午1.47.38.png

This is the first and most indispensable step, connect a wire from GND to the negative rail on the breadboard.

Setting Up Wires

截圖 2021-04-18 上午1.53.26.png
截圖 2021-04-18 上午1.53.39.png
截圖 2021-04-18 上午1.54.17.png
截圖 2021-04-18 上午1.54.54.png

(See the image above)

1. Plug a wire from 12 on the Arduino to the left side of the 220-ohm resistor.

2.Plug a resistor right beside the wire.

3.Plug a red LED on the bottom of the two components, make sure to match the right grid.

4.Plug a wire from 11 on the Arduino to the left side of the 220-ohm resistor.

5.Plug a resistor right beside the wire.

6.Plug a yellow LED on the bottom of the two components, make sure to match the right grid.

7.Plug a wire from 10 on the Arduino to the left side of the 220-ohm resistor.

8.Plug a resistor right beside the wire.

9.Plug a green LED on the bottom of the two components, make sure to match the right grid.

Decoration

截圖 2021-04-18 上午1.56.50.png

Coding

截圖 2021-04-18 上午1.57.42.png

Paste the following coding to the Arduino software and upload it.

Link: https://create.arduino.cc/editor/conniewu822/3e08...

const int green = 10; // Pin of the green LED

const int yellow =11; // Pin of the yellow LED

const int red = 12; // Pin of the red LED

void setup() {

pinMode(10, OUTPUT);

pinMode(11, OUTPUT);

pinMode(12, OUTPUT);

}

void loop() {

digitalWrite(10, LOW);

digitalWrite(11, LOW);

digitalWrite(12, HIGH);

delay(2000);

digitalWrite(10, LOW);

digitalWrite(11, HIGH);

digitalWrite(12, LOW);

delay(1000);

digitalWrite(10, HIGH);

digitalWrite(11, LOW);

digitalWrite(12, LOW);

delay(2000);

}

Testing

截圖 2021-04-18 上午12.46.59.png
截圖 2021-04-18 上午2.05.16.png
截圖 2021-04-18 上午2.05.30.png