Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this assignment, you will develop a simple traffic light control system for a four - way street intersection using Arduino Uno board. At the

In this assignment, you will develop a simple traffic light control system for a four-way street intersection
using Arduino Uno board. At the minimum, you must prepare 2 sets of traffic lights (each set consisting
of a Red, Yellow (Amber), and Green LEDs) of adjacent streets (or cross-streets, e.g., North and East)
and 2 switches (push-type) for pedestrians, one for each of the streets (e.g., one for North and other for
East). An example of circuit connection diagram for one set is shown below (left). You will need to
prepare 2 sets of this circuit for this assignment. Digital output pins and digital input pins needs to be
connected to your Arduino Digital pins (between pin 2 to 13).
GND
As a requirement for this assignment, you will need to prepare the circuit on a breadboard with proper
connection to your Arduino and write a software code using Arduino Sketch to control the LEDs in
proper sequence and allow the switch press to modify the timing of the sequence. Normally (if none of
the switches are pressed), the LEDs will turn on and off in this sequence: Red -> Green -> Amber -> Red
etc. with the given time delay mentioned later. As soon as one of the push buttons is pressed (on either of
the streets), the corresponding Amber (yellow) LED will light up, followed by Red for that side of the
street. The adjacent street must also have the opposite sequence (i.e., opposite to Red light is Green
followed by Amber). After Red light time expires, then the sequence will continue according to normal
timings. If the switch is pressed when the Red or Amber LED is ON, then the switch press will be
ignored.
To construct this setup, you can follow this procedure:
1) First make the LED circuits shown above. Use the breadboard to setup 2 sets of 3 LEDs (i.e.,6 LEDs
in total: 2 Red, 2 Yellow, and 2 Green). Each set will consist of one red (R), one yellow/amber (A),
and one green (G) LED. Each set will represent one direction of Traffic (i.e., one set for EW & another
set for NS). Each LED must have a series Resistance of 220(or 330) as shown. Digital output pins Digital input pin
VDD
2
2) Connect the LEDs to different Digital I/O pins of the Arduino Uno (you can use any Digital pin
between 2 to 13, e.g., for one set you can use pins 2,3, & 4, and for the other set you can use pins 6,7,
8). Refer to Tutorial 1 for further details of LED connections. (Note: Do not use digital pin 0 or 1.)
3) Following the Tutorial 1 code, write a test code to turn ON/OFF (blink) each LED independently (this
process ensures that your LEDs are connected properly). Note that you should change the digital pin
number in your test code to verify proper connection of each of the LEDs one by one (do not connect
multiple LEDs on a single digital pin). You can use this type of (partial) checking for correctness of
your (partial) hardware setup in any project circuit setup testing to avoid later pitfall (a strategy known
as Divide and Conquer!).
4) Next, you can start programming the state machine. Here you can use simple delay() statements. For
the timing of the LEDs (R->G->A->R->G->A etc.), use this following sequence and times for delays.
Note: The delay of red light needs to be equal to the total delay of green and amber lights this is a
constraint of the timing for traffic signal lights.
You also need to ensure the timing of the adjacent-street is operating opposite way (see the timing
diagram below), to allow proper traffic flow on both streets. An example timing diagram for the two sets
of lights are shown below. For instance, Traffic light set 1 can be for North (N) direction, and Traffic light
set 2 can be for East (E) direction.
5) Implement this first with properly thought out delay statements in Arduino Sketch. After completing
the code, upload the code to your Arduino and test LEDs for functionality.
6) Now, you can add two pedestrian switches. A pedestrian can press this switch to immediately change
the light to red so that he/she can cross the street. Set up the switches as given in the schematic above
for each set and connect the digital input pin to an available Digital pin (between 2 to 13, e.g. digital
pin 5 for one side and digital pin 9 for other side). Make sure these Digital pins are set as INPUT pin
in the setup(), for example pinMode(5, INPUT). Also, you need to read these inputs as digital logic
value in loop(), for example val1= digitalRead(5). You can then use val1 as Boolean logic
(TRUE/FASLSE) in your if statements. Note that the circuit shown above will produce logic 1(+5 V)
when the switch is not pressed and will produce logic 0(0 V) when pressed (a setup known as Active
Low).
7) Now you will need to update your code to accommodate this switch presses (i.e., if the LED color is
changing with proper timing as shown above when no switch is pressed, but if a switch is pressed
with corresponding LED in Green, the corresponding street LED needs to change to Amber followed
by Red, while the adjacent street LED needs to change to Green when other street light becomes Red.
The sequence will follow thereafter normally according to the timing diagram above.)
In the assignment report, provide the followings:
a) Briefly summarize the work including your objective, procedure, and key results. 5 secRED 4 secGREEN 1 secAMBER
3
b) Provide your code for this traffic light controller with sufficient comments to ensure the code is
understandable.
c) Draw a FSM diagram (such as StateChart) for your code.
d) Explain how you implemented the pedestrian switch to respond when pressed? Was it
instantaneous? What is the best-case delay and worst-case delay from the time when the switch
was pressed and the time when the Amber (yellow) LED turned on? Can this be improved? How?
e) Provide snapshots confirming successful download of the code from computer to Arduino board.
f) Provide a few pictures as evidence of successful prototyping of the hardware and operation of the
code with various combination of LEDs ON/OFF.
g) Did you encounter any technical challenge? How did you resolve it?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems Second East European Symposium Adbis 98 Poznan Poland September 1998 Proceedings Lncs 1475

Authors: Witold Litwin ,Tadeusz Morzy ,Gottfried Vossen

1st Edition

3540649247, 978-3540649243

Students also viewed these Databases questions