51a5b56d-2fe2-4d1e-8732-38d9b12231f7
51a5b56d-2fe2-4d1e-8732-38d9b12231f7
Team Members:
Karim Youssef
Saif Al-Mohannadi
Salahudin Abu-Munshar (Team Manager)
Mohammad Musmar
Abstract: This report delved into a detailed analysis of the Arduino microcontroller's design. The focus was on
creating a functional traffic light system employing basic components like a breadboard, LEDs, and resistors,
in conjunction with the Arduino board and its software tools. At the core of this setup was the microcontroller,
an integrated circuit customized for specific electronic tasks. We established connections between individual
LEDs and the Arduino using cables. Using Arduino software, we programmed a sequence mimicking traffic
light patterns through the 'blink' feature. The timings for these patterns were meticulously adjusted and verified
using a timer to ensure accuracy. The entire system was successfully set up with active high configurations for
both input and output signals.
Introduction:
Keywords: Arduino, Microcontroller, LED’s, Traffic Lights, Breadboard _
During this lab, the essential items required to construct the traffic light system were:
The initial step of the lab procedure was to open a Lab computer equipped with the Arduino IDE application
and run the Arduino program which was set up using Board: Arduino/Genuino Uno and Port: COM6. Then, a
circuit that connects the Arduino board, LED, and resistor was created and a new Arduino code was written
and modified based on the created circuit and based on the location in which the pins were placed. The initial
aim was to establish a connection between the Arduino board and the computer using a USB cable. When the
connection is successful, a green LED on the board confirms it.
Subsequently, we adhere to the project objectives to construct a two-road traffic light system. The next step
was to adjust the delay time. This was done and edited based on the following times provided in (Table 1):
3000ms, 5000ms, and 10000ms, and the corresponding time in seconds were recorded in the same table. Based
on the findings in Table 1, we found that the delay time in Arduino code represents a time in milliseconds(ms),
therefore, by using the method of dimensional analysis, Experiment 2 was conducted by converting 0.5s to
(ms), and the new time in (ms) was placed in the delay () function.
Moving onto experiment 3, the LED was tasked and set to blink in a specific manner, therefore, for each given
time in experiment 3, and by converting the times in (s) to (ms) the code was modified and experiment 3 was
accomplished. For experiment 4, to simulate the traffic light system in Qatar, green and yellow LEDs were
added to the circuit and were placed in pins 10 and 1, respectively. Moreover, two resistors and jumper wires
were added to the circuit connection between the Arduino and the breadboard, and the code was modified. For
experiment 5, the same code as experiment 4 was updated using a “for”loop.
4.Results:
Table 1 - Results Table Representing Delay Time in code in Milliseconds compared to
Real Interval Time and Time Measured in Seconds
Delay Time in Code (MilliSeconds) Real Time Interval (Seconds) Actual Time Measured (Seconds)
3000 3 3.05
5000 5 4.95
10000 10 9.98
5.Questions:
Q1: Never connect an LED directly to the power supply pins (5 V). Why?
It is very important to avoid directly connecting any LED to a 5V power supply port on the Arduino. The
reason for this precaution is because excessive current flow, which can occur if not properly monitored, can
potentially cause damage to both the LED and the Arduino circuit board. To avoid this risk, LEDs are typically
connected in series with a low-watt resistor. This resistor
Figure 1 - Code for experiment 1 (3000ms)
To get the LED to blink every half second `delay(500)` was used, this was the change made in the code instead
of using `delay(3000)`, `delay(5000)`, and `delay(10000)` that was used in the previous part of the experiment.
Q3: Suppose we want the LED to blink with the following pattern: it stays on for 1 second, stays off for 1
second, then stays on for 2 seconds, then stays off for 2 seconds, and then repeats. Write the modified Arduino
code sketch to implement this pattern for the blinking LED.
In the above code, an LED is configured to turn on for one second, turn off for one second, and then repeat the
cycle of turning on for two seconds and off for two seconds. This behavior is achieved by a straightforward
implementation technique. The desired LED pattern is produced by this code, which generates a visual signal
that alternates between 1- and 2-second intervals of illumination and darkness.
Q4: Write an Arduino sketch that will simulate traffic light system in Qatar roads using Green, yellow, and red
LEDs.
Initially all the LEDs are OFF then the traffic light follows the following steps:
Step 1: Green LED ON for 5 sec, yellow LED OFF, and red LED OFF.
Step 2: Green LED is blinking (On/Off) 3 times for 3 sec, yellow LED OFF, and red LED OFF. Step 3: Green
LED OFF, yellow LED is blinking 3 times for 3 sec, and red LED OFF.
Step 4: Green LED OFF, yellow LED OFF, and red LED ON for 5 sec.
Q5: Update the code in experiment 4 using for statement to repeat the block of LEDS blinking:
Figure 8 - Code for Experiment 5 of Traffic Light Simulation using For Loops
For experiment 5, The initial approach for simulating a traffic light was less efficient because it involved
manually repeating the same commands to control the LED pattern. In contrast, a more efficient solution is
employed for loops, which are designed to run a sequence of actions for a specified number of iterations. In
this case, all the loops needed to run three times, which is why the conditions within the for statements utilized
the variable 'i.' This variable started at 1, incremented with each iteration, and the loops terminated when 'i'
reached 3.