Traffic Light Model (Arduino) With Sensors
by mrbrightedu in Circuits > Arduino
25 Views, 1 Favorites, 0 Comments
Traffic Light Model (Arduino) With Sensors
This project is an example of a simple two-direction traffic light system with a timer and two sensors. Traffic light systems are also a common state machine/diagram example. This project helps explore the state concept of system design. You will also learn how to integrate input actions (e.g. button press) alongside a timer.
Review the state diagram to understand the four possible light configurations and how we get to the next state, either by time, or by a button press. This button press could represent a sensor to detect a car on the road, or a pedestrian crosswalk.
Supplies
Arduino Components:
- Arduino Uno or compatible board (1x)
- USB cable for programming and power (1x)
.LEDs:
- Green LEDs (2x)
- Yellow LEDs (2x)
- Red LEDs (2x)
Resistors:
- 220Ω - 1KΩ resistors for LEDs (6x)
Push Buttons:
- Momentary push buttons (2x)
Wires and Connectors:
- Male-to-male jumper wires (10x)
- Breadboard (1x)
Install LEDs
As noted in the video, bend each LED such that the longer leg (positive) is bent to make it easier to place on the board.
Insert the six LEDs into the breadboard as per the diagram below.
Each LED is powered by a PIN, through a RESISTOR, and back to GROUND.
Take the time and care to position the components neatly and consistently. The more effort you put into designing an organized project, the more successful your project will become!
Install Buttons
Install the two buttons as shown. Remember to space them evenly and consistently.
Don't forget the two connections to the ground rail.
Downloads
Upload Arduino Sketch
Use the code attached here to configure the board. Open this sketch as a new project. Be sure to select the Arduino Uno board communication port specific to your hardware in the IDE.
Please upload when you have successfully connected and selected the Arduino board in the IDE.
Review the code comments for a description of each section and function.