Traffic Light Simulator
This Arduino project combines buttons and lights to make a nice little traffic light simulator in a Cross way. Have fun and observe! I have made some changes, including button coding and differences in the traffic lights. This projects includes 2 sets of traffic lights to create a realistic Cross way.
Materials:
Here are the materials needed:
- your Arduino board
- a breadboard
- six led lights (2 greens, 2 red, 2 yellow)
- a button of your choice
- 6 resistors (220ohm)
- 10 or more wires
Attach the First Led Light
Attach your wire to pin 8 on the Arduino board, and the other side to the positive leg on your led. On the negative leg, attach a resistor. Attach the other side of the resistor to Ground (negative) on the breadboard.
Attach Second and Third Lights
Connect the yellow and green lights the same way as step one
- yellow can be connected to pin 9
- green can be connected to pin 10
Connect Second Traffic Light
Connect the second set of traffic light in the Cross way for a realistic simulation. Steps are the same as previous.
- red can be connected to pin 11
- yellow can be pin 12
- and green can be connected to pin 13
Button Connection
Add a button onto the breadboard. Connect a resistor onto the bottom left corner, attaching it onto the Ground (negative) on the other end. Attach a wire on the bottom right corner of the button, and the other side to the power rail (positive) of the breadboard. Lastly, connect a wire to the top part of the button, and the other side to pin 2.
Power It Up
Connect a wire from 5v to the Ground on the breadboard (negative)
And a wire from Gnd to the power rail on the breadboard (positive)
Coding
Add a base if you want to.
Here is my code:
https://create.arduino.cc/editor/kai012345/fd8c3502-cd47-4bc6-9982-d1fc4fd84ab5/preview
Here is my final result: