Sie sind auf Seite 1von 43

CHAPTER ONE

INTRODUCTION
1.1

Background of Study
Poor road traffic management is the primary reason for extended periods of traffic congestion
throughout the world. The issue of traffic congestion has affected both the developing and
developed economies to different degrees irrespective of the measures taken to curb the issue. A
common feature across road networks in many urban regions in the developing world is the
presence of critical congestion areas; we refer to a critical congestion area as one where a
network of roads converge and a large amount of traffic needs to traverse the common
congestion area. Most of the techniques already in use for controlling the traffic operate on a
timing mechanism that changes the light after a given interval. As a result drivers spend
unnecessary time waiting for the traffic lights to change. On the other hand, modern traffic light
systems sense the presence or absence of cars and react accordingly. In particular, this project
designs a microcontroller sensor based intelligent traffic light control system. The system
receives inputs from sensor (ultrasonic) which indicate the traffic load or number of cars on each
lane for the given intersection, and hence it computes the time for each lane which is directly

proportional to the number of cars on that lane.


1.2 Statement of Problem
The method which has been in use for years does not allow the microcontroller to consider the
most congested lane in order to give priority so as to reduce the waiting time of the vehicles.
This project will allocate more time to the lane that has highest traffic on a T- junction by using
an ultrasonic transceiver module to sense the traffic density.

1.3

Motivation

With the advent of ultrasonic sensors technology and microcontroller, traffic control systems can
be improved with the sensors having the ability to know which lane has more traffic congestion
and allocating more time in other words reducing the wait time.
1.4

Aim and Objectives


The aim of this project is to design and construct a sensor based traffic light control system for Tjunction road using Ultrasonic sensors and a microcontroller. The objectives include:
1. To apply the flexibility of microcontroller in controlling traffic light system.
2. To reduce congestion and accident on the road by increasing movement time on
congested lanes.
3. To replace the use of traffic wardens on the roads, which are by far less effective and
expensive to maintain than the automated method.
4. To improve high accuracy in traffic control on the roads i.e. to overcome limitations
caused by human nature such as fatigue, distractions etc, resulting to poor control
performance.

1.5

Methodology
The software program for the monitoring system is achieved using EPROM and is encoded into
the Arduino UNO microcontroller. Hence it is the microcontroller that then allocates time for
each signal to reduce traffic congestion and minimize delays based on the program encoded into
it. The functional block diagram of the traffic light system is shown in figure 1.1 which consists
of four blocks starting with the power supply which supplies power to the entire blocks. The
second block is the sensor circuit which is the ultrasonic transceiver for sensing vehicles on each
lane. The third block is the processor that controls the timing sequence of the operation. Finally,
the fourth block is the display which is the light emitting diode (LED).

Power supply
2

Sensor

Processor

Display Unit

Figure 1.1: Block Diagram of a Traffic Light Control for a Robotic System
1.6

Limitation
This project dwells primarily on the hardware design (sensor type, sensor placement) and
software design to implement a sensor based traffic light control system and develop a new
method to enhance the existing traffic light control system for cross junctions.

1.7

Outline of Report
This project consists of five chapters, chapter one deals with the background of study, statement
of problem, motivation, aim and objectives, methodology, limitation of work and outline of
report. Chapter two deals with the literature review, chapter three deals with the design, chapter
four deals with construction, testing and packaging, while chapter five deals with the conclusion
and recommendation.

CHAPTER TWO
LITERATURE REVIEW
2.1

Introduction
The challenge of minimizing accidents caused by unregulated traffic flow led traffic engineers to
start thinking of different ways of controlling traffic particularly at road junctions. The methods
3

of traffic control used over the years other than the use of traffic wardens are the construction of
flyover and bypass roads, creating ring roads, and construction of conventional traffic light based
on counters. The human traffic control remains the most preferred because it makes the better
decision of reducing traffic jams, congestions, and road accidents. The traffic wardens are
considered to be better because of their ability to handle emergencies (Subramaniam et al.,
2012). The neural-networks of a traffic controller can assess traffic in visual range, and take
intelligent and adaptive decisions. Transportation researchs goal is to optimize transportation
flow of people and goods. As the number of road users constantly increases while resources
provided by current infrastructures are limited, intelligent control of traffic became a very
important issue.
2.2

Review of Related Works


Li (2011) states that the theme is to control the traffic by determining the traffic density on each
side of the road and control the traffic signal intelligently by using the density information. The
paper presents the algorithm to determine the number of vehicles on the road. The density
counting algorithm works by comparing the real time frame of live video by reference image and
by searching vehicle in the Region of Interest. In this technique in order to deal with noises
added due to different lightening conditions at different times of the day, a set of reference
images have been stored at different time slots of the day. The system cycles through these
reference images according to the current time of the day. Image processing techniques and
wireless communication networks can avoid traffic congestion for day time sequences efficiently.
This particular method uses ZIGBEE protocol to wirelessly transmit the information of the road
scene. This information will be displayed nearby the roads which can help people by providing

pre knowledge of traffic jams and congestions. Studies about traffic flow optimization show that
traffic congestion can be reduced using the self-algorithm method (Subramaniam et al., 2012).
The method is made up by combination of the sequencing programming method and the sensor
based programming method, with a programmable logic controller (PLC) as the main controller,
thus this traffic jam congestion detection method is based on various techniques: change
detection, image processing and incorporation of prior information such as traffic model and
road network. This method, after analysing the density of traffic, manipulates the timer for green
light as per the density on each road. Another technique for traffic management at crossroad was
given in the review which uses surveillance cameras and electronic sensors in order to find out
the number of vehicles. The basic technique is background subtraction. Here an image of the
road without any traffic is stored in the processor and then its comparison is done with the real
time image. The less the image is matched the more is the traffic on the road. Hence the green
light is ON for a longer period of time. Edge detection technique is used for image matching.
Canny edge detector is used as this is the most efficient one and can further be used for contour
tracing. After detecting the edges and subtracting the background, number of vehicles on the road
can be calculated. In the drawbacks of infrared and radio frequency were resolved as the basic
requirement of these systems is, a transmitter circuit has to be installed at every traffic signal.
The algorithm was inspired by YUN-CHANG who used artificial intelligence for traffic control
using fuzzy mapping. In colour detection and coordinate analysis of the detected colour has been
used. The colour detection for various UGVs was used which generated a stop signal at the
traffic light whenever traffic on the other road was found more dense. This algorithm had the
most optimum execution time. Another algorithm for intelligent traffic control unit was given in.
Here Pallavi gave a technique for the use of traffic density for controlling the lights by edge

detection. Here binary images with pixels detected are used by common operators Sobel and
Laplace. After edge detection the matching is done on the bases of edges in the image with the
reference image stored in the processor. Depending upon the percentage of matching the timer
for green and red light is controlled. A very different system was built by Ryan and Guohui
Zhang, where object tracking was done on the bases of vehicle length in a video frame. They
followed Video based Vehicle Detection and Classification (VVDC). They made the
algorithm/technique which corrected the 97% truck count error and brought it down to 9%.
Hence this made the traffic control system efficient by taking the size of vehicle in to account.
The bigger vehicles were found on the road, the greater time was allotted to them for crossing the
traffic light. Traffic congestion reduction can also be enhanced using the embedded system and
GSM mobile phone (Shilpa et al., 2009). Using the embedded system, the traffic jam will be
reduced by increasing the green signal time on busy road and increasing the red signal time in
non-busy roads.
2.3

Present Research Work


The present research work will adopt different approaches from the reviewed works. The
approach of (Subramaniam et al., 2012) will be adopted because of the self- algorithm
programming, but replacing the PLC with a microcontroller because the PLC have the
disadvantages of being bulky, expensive and are not easily adapted to high speed I/O while the
microcontroller is less bulky and cheaper. The method used by Adenote, (2012). will also be
adopted, but in this case, the LDR will be replaced with an Ultrasonic sensor. Therefore, with
these approaches combined, a better performance could be obtained. This method will therefore
reduce waiting time, minimize traffic congestion and give consideration for the with more
traffic.

2.4

Comparative Analysis
The old method of traffic control, such as the construction of ring roads, roundabouts and bypass
does not detect congestion. The ring roads and the bypass only divert traffic while the
roundabout requires more space and money to construct compared to the automated traffic
control method. Using the human method of traffic control, the traffic wardens life may be
endangered because he has to stand in the middle of the road to carry out his duties. This method
is not just unsatisfactory but has limitations due to human nature such as fatigue and distraction
resulting in control errors. The implementation of a smart traffic control system increases the
efficiency of the traffic warden and reduces his /her work to that of monitoring and enforcement
of traffic laws. The automated traffic control method on which this project will focus will be
much more effective by being able to emulate the human traffic system and also takes care of
limitations such as cost, space and congestion of vehicles.

CHAPTER THREE
DESIGN ANALYSIS
3.1

Introduction
This chapter discusses the design of this project; the main aim of this project is to design a
directional movement of a robotic traffic control system. The project has two major phases; the
7

hardware design and the software implementation which is used to develop the control
mechanism of the system.
This project was designed using 8051 microcontroller as the main component unit. This makes
the circuit layout simple and portable while the basic logic behind its operation lies on the
operation of the ultra sonic sensor and the microcontroller.
3.2

Hardware Design
The design of the directional movement of a robotic traffic control system concerns the design of
its component units which are made up of but not limited to the following:
i.
ii.
iii.
iv.
v.

Ultrasonic sensor
LEDs
Arduino UNO Microcontroller
Resistor
Capacitor

All the above listed components will be integrated to form the complete prototype, The
hardware components are the backbone of the system. More detailed information of each
component will be discussed in the following sections.
3.3

Design Specification
Input voltage = +5 V
Operating voltage = 5 V
Operating current = 310mA

3.4

Design Analysis

The design of this project is to realize a traffic light for a robotic system control that could be
achieved based on the coordinate operation of the ultrasonic sensor, microcontroller (arduino)
and the LEDs.

Figure 3.1 Circuit Diagram of a traffic light control for a Robotic System
3.5

HCSR04 Ultrasonic Sensor


The HC-SR04 ultrasonic sensor uses sonar to determine distance to an object like bats or
dolphins do. It offers excellent range accuracy and stable readings in an easy-to-use package. It
operation is not affected by sunlight or black material like Sharp rangefinders are (although

acoustically soft materials like cloth can be difficult to detect), similar in performance to the
SRF005 but with the low-price of a Sharp infrared sensor.
Ultrasonic waves are used to enable stable detection of transparent objects, such as transparent
films, glass bottles, plastic bottles, and plate glass, using Through-beam or Reflective Sensors.
The pictorial view of the ultrasonic sensor HCSR04 is reviewed in figure 3.2.

Figure 3.2: Ultrasonic Sensor


The ultrasonic sensor has the following Specification
1. Working Voltage: 5V (DC)
2. Working Current : max 15mA
3. Working frequency: 40HZ
4. Output Signal: 0-5V (Output high when obstacle in range)
5. Sentry Angle : max 15 degree
6. Sentry Distance : 2cm - 400cm
7. High-accuracy : 0.3cm
8. Input trigger signal : 10us TTL impulse
9. Echo signal : output TTL PWL signal
10. Size : 45*20*15mm
If the height of the ultra sonic sensor is place 43cm and it has sentry angle of 15 o, then figure
3.2, shows the distance from the sensor to the point of intersection and the distance between that
point and the sensor. The point of intersection of trigger ray and the ground can be calculated as
follows:

10

15O
43cm

Figure 3.3: Triangular Representation of The Sensor and The Point of Contact.
Applying trigonometrical ratios (SOHCAHTOA)
Cos15=

43 cm
HYP

HYP =

43 cm
cos 15

HYP =

43 cm
0.965926

HYP = 44.5cm
But if the distance from the robot to that point of contact is x, we could apply Pythagoras
theorem of still trigonometrically ratio:
Tan15=

x
43

X= 43Tan15
X=11.5cm
3.6

LEDs (Output Interface Design)


LEDs (Light Emitting Diodes) are electronic components that convert a portion of the current
flowing through them into light. The intensity of the light produced vary with the current
flowing. To keep the current at or below the recommended operating current level, LEDs are
11

typically connected in series with a current limiting resistor.The size of the resistor needed to
limit the current through the LED to the desired value is calculated using Ohms law as follows,
the value of resistor is determine by:

R=

V CC V Z
(3.1)
IZ

R=

50.6
10 103

R=440 .
Thus, the output interface design is simply an LED display board with three different colors
including RED, YELLOW and GREEN. Fig. 3.4 shows the arrangement of the LEDs in the
output interface.
D1,D2,D3

R1

D4,D5,D6

R2

D7,D8,D9

R3

D9,D10,D11

R4

12

Figure 3.4: LED Output Interface


3.7

Power Supply Unit


My power supply for the project is a solar power using pulse width modulation provided by our
colleague handling the power supply unit of the project. Base on the component requirements, a
5volt, 2amperes has been provided.

3.8

Arduino UNO
The Arduino UNO is a microcontroller board based on the ATmega328P. It is a surface mount
breadboard embedded version with integrated USB. It is a smallest, complete, and breadboard
friendly. It has everything that Diecimila/Duemilanove has (electrically) with more analog input
pins and onboard +5V AREF jumper. Physically, it is missing power jack.
"Uno" means one in Italian and was chosen to mark the release of Arduino Software (IDE) 1.0.
The Uno board and version 1.0 of Arduino Software (IDE) were the reference versions of
Arduino, now evolved to newer releases. The Uno board is the first in a series of USB Arduino
boards, and the reference model for the Arduino platform; for an extensive list of current, past or
outdated boards see the Arduino index of boards. Figure 3.5 shows the pictorial diagram of
Arduino UNO front and rear view.

13

Figure 3.5: Arduino UNO front view

3.8.1

Technical specification

Microcontroller
Operating Voltage
Input Voltage (recommended)
Input Voltage (limit)
Digital I/O Pins
PWM Digital I/O Pins
Analog Input Pins
DC Current per I/O Pin
Flash Memory
SRAM

ATmega328P
5V
7-12V
6-20V
14 (of which 6 provide PWM output)
6
8
40 Ma
32KB(of which 2KB used by bootloader)
2 KB (ATmega328P)
14

EEPROM
Clock Speed
Dimension

3.8.2

1 KB (ATmega328P)
16 MHz
0.73" x 1.70"

Power:
The Arduino Nano can be powered via the Mini-B USB connection, 6-20V unregulated
external power supply (pin 30), or 5V regulated external power supply (pin 27). The power
source is automatically selected to the highest voltage source.
The FTDI FT232RL chip on the Nano is only powered if the board is being powered over
USB. As a result, when running on external (non-USB) power, the 3.3V output (which is
supplied by the FTDI chip) is not available and the RX and TX LEDs will flicker if digital pins
0 or 1 are high.

3.8.3

Memory:
The ATmega168 has 16 KB of flash memory for storing code (of which 2 KB is used for the
bootloader); the ATmega328 has 32 KB, (also with 2 KB used for the bootloader). The
ATmega168 has 1 KB of SRAM and 512 bytes of EEPROM (which can be read and written
with the EEPROM library); the ATmega328 has 2 KB of SRAM and 1 KB of EEPROM.

3.8.4

Input and Output


Each of the 14 digital pins on the microcontroller can be used as an input or output, using
pinMode(), digitalWrite(), and digitalRead() functions. They operate at 5 volts. Each pin can

15

provide or receive a maximum of 40mA and has an internal pull-up resistor (disconnected by
default) of 20-50 kOhms. In addition, some pins have specialized functions:
1. Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data.
These pins are connected to the corresponding pins of the FTDI USB-to-TTL Serial
chip.
2. External Interrupts: pin 2 and 3. These pins can be configured to trigger an interrupt
on a low value, a rising or falling edge, or a change in value. See the attachInterrupt()
function for details.
3. PWM: pin 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analogWrite()
function.
4. SPI (pin 10): SS,( pin 11) MOSI, (pin 12 ) (MISO), 13 (SCK). These pins support
SPI communication, which, although provided by the underlying hardware, is not
currently included in the Arduino language.
5. LED (pin 13): There is a built-in LED connected to digital pin 13. When the pin is
HIGH value, the LED is on, when the pin is LOW, it's off.
The UNO has 6 analog inputs, each of which provide 10 bits of resolution (i.e. 1024
different values). By default they measure from ground to 5 volts, though is it possible to
change the upper end of their range using the analogReference() function. Additionally,
some pins have specialized functionality:
I2C: 4 (SDA) and 5 (SCL). Support I 2C (TWI) communication using the Wire library
(documentation on the Wiring website).
There are a couple of other pins on the board:
1. AREF: Reference voltage for the analog inputs. Used with analogReference().

16

2. Reset: Bring this line LOW to reset the microcontroller. Typically used to add a reset
3.8.5

button to shields which block the one on the board.


Communication
The Arduino UNO has a number of facilities for communicating with a computer, another
Arduino, or other microcontrollers. The ATmega168 and ATmega328 provide UART TTL (5V)
serial communication, which is available on digital pins 0 (RX) and 1 (TX). An FTDI
FT232RL on the board channels this serial communication over USB and the FTDI drivers
(included with the Arduino software) provide a virtual com port to software on the computer.
The Arduino software includes a serial monitor which allows simple textual data to be sent to
and from the Arduino board. The RX and TX LEDs on the board will flash when data is being
transmitted via the FTDI chip and USB connection to the computer (but not for serial
communication on pins 0 and 1).
A Software Serial library allows for serial communication on any of the Nano's digital pins.
The ATmega168 and ATmega328 also support I2C (TWI) and SPI communication. The
Arduino software includes a Wire library to simplify use of the I2C bus; see the documentation
for details. To use the SPI communication, please see the ATmega168 or ATmega328 datasheet.

3.8.6

Programming
The Arduino UNO can be programmed with the Arduino software (download). Select "Arduino
Diecimila, Duemilanove, or Nano w/ ATmega168" or "Arduino Duemilanove or Nano w/
ATmega328" from the Tools > Board menu (according to the microcontroller on your board).
For details, see the reference and tutorials. The ATmega168 or ATmega328 on the Arduino
UNO comes preburned with a bootloader that allows you to upload new code to it without the
17

use of an external hardware programmer. It communicates using the original STK500 protocol
(reference, C header files). You can also bypass the boot loader and program the
microcontroller through the ICSP (In-Circuit Serial Programming) header; see these
instructions for details.
3.8.7 Automatic (Software) Reset
Rather than requiring a physical press of the reset button before an upload, the Arduino UNO is
designed in a way that allows it to be reset by software running on a connected computer. One of
the hardware flow control lines (DTR) of the FT232RL is connected to the reset line of the
ATmega168 or ATmega328 via a 100 nanofarad capacitor. When this line is asserted (taken low),
the reset line drops long enough to reset the chip. The Arduino software uses this capability to
allow you to upload code by simply pressing the upload button in the Arduino environment. This
means that the bootloader can have a shorter timeout, as the lowering of DTR can be wellcoordinated with the start of the upload.
This setup has other implications. When the microcontroller is connected to either a computer
running Mac OS X or Linux, it resets each time a connection is made to it from software (via
USB). For the following half-second or so, the boot loader is running on the UNO. While it is
programmed to ignore malformed data (i.e. anything besides an upload of new code), it will
intercept the first few bytes of data sent to the board after a connection is opened. If a sketch
running on the board receives one-time configuration or other data when it first starts, make sure
that the software with which it communicates waits a second after opening the connection and
before sending this data.
3.8.8 Communication and the configuration
18

Differences with other boards


The Uno differs from all preceding boards in that it does not use the FTDI USB-to-serial driver
chip. Instead, it features the Atmega16U2 (Atmega8U2 up to version R2) programmed as a USBto-serial converter.
Power
The Uno board can be powered via the USB connection or with an external power supply. The
power source is selected automatically.
External (non-USB) power can come either from an AC-to-DC adapter (wall-wart) or battery.
The adapter can be connected by plugging a 2.1mm centre-positive plug into the board's power
jack. Leads from a battery can be inserted in the GND and Vin pin headers of the POWER
connector.
The board can operate on an external supply from 6 to 20 volts. If supplied with less than 7V,
however, the 5V pin may supply less than five volts and the board may become unstable. If using
more than 12V, the voltage regulator may overheat and damage the board. The recommended
range is 7 to 12 volts.
The power pins are as follows:
1. Vin: The input voltage to the Uno board when it's using an external power source (as
opposed to 5 volts from the USB connection or other regulated power source). You can
supply voltage through this pin, or, if supplying voltage via the power jack, access it
through this pin.
2. 5V: This pin outputs a regulated 5V from the regulator on the board. The board can be
supplied with power either from the DC power jack (7 - 12V), the USB connector (5V),

19

or the VIN pin of the board (7-12V). Supplying voltage via the 5V or 3.3V pins bypasses
the regulator, and can damage your board.
3. 3V3: A 3.3 volt supply generated by the on-board regulator. Maximum current draw is 50
mA.
4. GND: Ground pins.
5. IOREF: This pin on the Uno board provides the voltage reference with which the
microcontroller operates. A properly configured shield can read the IOREF pin voltage
and select the appropriate power source or enable voltage translators on the outputs to
work with the 5V or 3.3V.
Memory
The ATmega328 has 32 KB (with 0.5 KB occupied by the bootloader). It also has 2KB of SRAM
and 1 KB of EEPROM (which can be read and written with the EEPROM library).
Input and Output
Each of the 14 digital pins on the Uno can be used as an input or output, using pinMode (),
digitalWrite (), and digitlRead () functions. They operate at 5 volts. Each pin can provide or
receive 20 mA as recommended operating condition and has an internal pull-up resistor
(disconnected by default) of 20-50k ohm. A maximum of 40mA is the value that must not be
exceeded on any I/O pin to avoid permanent damage to the microcontroller.
In addition, some pins have specialized functions:
1. Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data.
These pins are connected to the corresponding pins of the ATmega8U2 USB-to-TTL
Serial chip.

20

2. External Interrupts: 2 and 3. These pins can be configured to trigger an interrupt on a low
value, a rising or falling edge, or a change in value. See the attachInterrupt() function for
details.
3. PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analogWrite() function.
4. SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication
using the SPI library.
5. LED: 13. There is a built-in LED driven by digital pin 13. When the pin is HIGH value,
the LED is on, when the pin is LOW, it's off.
6. TWI: A4 or SDA pin and A5 or SCL pin. Support TWI communication using the Wire
library.

The Uno has 6 analog inputs, labelled A0 through A5, each of which provide 10 bits of
resolution (i.e. 1024 different values). By default they measure from ground to 5volts
There are a couple of other pins on the board:
1. AREF. Reference voltage for the analog inputs. Used with analogReference().
2. Reset. Bring this line LOW to reset the microcontroller. Typically used to add a reset
button to shields which block the one on the board.
3.8.9 Serial Communication
The Uno has a number of facilities for communicating with a computer, another Uno board, or
other microcontrollers. The ATmega328 provides UART TTL (5V) serial communication, which
is available on digital pins 0 (RX) and 1 (TX). An ATmega16U2 on the board channels this serial
communication over USB and appears as a virtual com port to software on the computer. The
16U2 firmware uses the standard USB COM drivers, and no external driver is needed. However,

21

on Windows, a .inf file is required. The Arduino Software (IDE) includes a serial monitor which
allows simple textual data to be sent to and from the board. The RX and TX LEDs on the board
will flash when data is being transmitted via the USB-to-serial chip and USB connection to the
computer (but not for serial communication on pins 0 and 1).
Programming
The Uno can be programmed with the Arduino Software (IDE). Select "Arduino/Genuino Uno"
from the Tools > Board menu (according to the microcontroller on your board).
The ATmega328 on the Uno comes preprogrammed with a boot loader that allows you to upload
new code to it without the use of an external hardware programmer. It communicates using the
original STK500 protocol (reference, C header files).
You can also bypass the bootloader and program the microcontroller through the ICSP (InCircuit Serial Programming) header using Arduino ISP or similar; see these instructions for
details.
The ATmega16U2 (or 8U2 in the rev1 and rev2 boards) firmware source code is available in the
Arduino repository. The ATmega16U2/8U2 is loaded with a DFU bootloader. which can be
activated by:
1. On Rev1 boards: connecting the solder jumper on the back of the board (near the map of
Italy) and then resetting the 8U2.
2. On Rev2 or later boards: there is a resistor that pulling the 8U2/16U2 HWB line to
ground, making it easier to put into DFU mode.
You can then use Atmel's FLIP software (Windows) or the DFU programmer (Mac OS X and
Linux) to load a new firmware. Or you can use the ISP header with an external programmer
(overwriting the DFU boot loader). See this user-contributed tutorial for more information.

22

Software Implementation
A Software Serial library allows serial communication on any of the Uno's digital pins.
The ATmega328 also supports I2C (TWI) and SPI communication. The Arduino Software (IDE)
includes a Wire library to simplify use of the I2C bus; For SPI communication, you can use the
SPI library.
Automatic (Software) Reset
Rather than requiring a physical press of the reset button before an upload, the Uno board is
designed in a way that allows it to be reset by software running on a connected computer. One of
the hardware flow control lines (DTR) of the ATmega8U2/16U2 is connected to the reset line of
the ATmega328 via a 100 nanofarad capacitor. When this line is asserted (taken low), the reset
line drops long enough to reset the chip. The Arduino Software (IDE) uses this capability to
allow you to upload code by simply pressing the upload button in the interface toolbar. This
means that the boot loader can have a shorter timeout, as the lowering of DTR can be wellcoordinated with the start of the upload.
This setup has other implications. When the Uno is connected to either a computer running Mac
OS X or Linux, it resets each time a connection is made to it from software (via USB). For the
following half-second or so, the boot loader is running on the Uno. While it is programmed to
ignore malformed data (i.e. anything besides an upload of new code), it will intercept the first
few bytes of data sent to the board after a connection is opened. If a sketch running on the board
receives one-time configuration or other data when it first starts, make sure that the software with
which it communicates waits a second after opening the connection and before sending this data.

23

The Uno board contains a trace that can be cut to disable the auto-reset. The pads on either side
of the trace can be soldered together to re-enable it. It's labelled "RESET-EN". You may also be
able to disable the auto-reset by connecting a 110 ohm resistor from 5V to the reset line.
3.9

Operating Sequence
The sequences by which the traffic flow signal will be operated is shown in Table 3.1. In the
table of traffic, Go is represented by logic 1 and Stop is represented by logic 0.
Table 3.1: Traffic Flow Sequences of Operation:

S/NO

1
2
3
4
5
6
7
8
9

LANE 1

LANE 2

LANE 3

RYG

RYG

RYG

100
1 10
001
01 1
100
100
100
100
100

100
1 00
100
110
001
011
100
100
100

100
100
100
100
100
1 10
001
011
100

The sequence of operation of this system is developed based on the traffic flow rules and
regulations as found in the high way code. In the high way code, the GO signal is indicated by a
green light, the STOP signal is indicated by a red light and the warning signal of either GET
READY TO GO or GET READY TO STOP is indicated by a combination of red and yellow or
green and yellow respectively. Based on this information, the operating sequence table is
developed as in Table 3.1.
24

START

3.10 Software Design


POWER ON

With the hardware implementation completed, a set of instructions (programs) was developed to
TURN ON RED LIGHT AND DELAY

aid the hardware to perform the required task. The software was developed using C programming
language. The detail of the source code is as shown in appendix I.
3.11 The Process Flow Chart
The traffic
sequenceON
is based
CARS flow
AVAILABLE
LANEon
1?a clockwise and anti clockwise rotation from lane 1 to lane
TURN ON RED LIGHT AND DELAY

2, lane 2 to lane 1 then to the lane 3. The operation is interrupted only by presence of cars as
follows:

TURN ON YELLOW AND DELAY

CHECK NEXT LANE

3.11.1 Flow Chart


ON GREEN AND DELAY
TheTURN
program
starts by first of all initializing the sensors, and then it turns ON the LEDs
CARS flow
AVAILABLE
ONofLANE
2? shown in Table 3.1. After
according to demand based on the traffic
sequences
operation

TURN ON RED LIGHT AND DELAY

that, it goes to the next lane. Figure 3.6 shows the flow chart for all the lanes.
TURN ON YELLOW AND DELAY

POWER OFF

CHECK NEXT LANE

TURN ON GREEN AND DELAY


STOP
CARS AVAILABLE ON LANE 3?

NO

TURN ON YELLOW AND DELAY

POWER OFF

STOP

YE
S

TURN ON GREEN AND DELAY

NO

POWER OFF

25
STOP
NO

YE

NO

YE
YE S

NO

YE

YE

STOP
NO

CHAPTER FOUR
CONSTRUCTION, TESTING AND RESULT
4.1

Introduction
This chapter contains the construction work in detail, the precautions taken before soldering, it
also contain the result analysis.

4.2

Construction
The basic materials needed for this project were bread board, Vero board, a transparent plastic
frame to house the electronic components, and the entire layout in order to secure the
components

26

4.2.1

Bread Boarding and Vero Boarding


The construction of this work was done first by assembling the components on a bread board.
When the system worked as expected after series of test has been carried out, the components
were then transferred to a Vero board. In this construction, the vero board was cleaned with an
iron brush to remove dirt from its surface which might affect the soldering quality.
Subsequently, following the circuit diagram, the components were mounted on the board one
after the other and soldered. The IC was not directly soldered on the board but was mounted on
an IC socket which was soldered on the board. This is to prevent heat damage and for ease of
replacement. While the DC power supply and other components were connected to the board via
flexible wires. Fig.4.1 shows the layout of the components used for construction.

27

Figure 4.1: Picture of Soldered Components


4.2.2

Packaging
This project prototype was packaged in a transparent plastic frame in order to enhance visibility,
protect the components and layout from dust, and of course to make it look attractive. The LEDs
were positioned at the appropriate location to stimulate proper traffic control.
Thus, the construction has been carried out in proper way to ensure we have the expected result.
The soldering was cleaned and tested with caution to have a good work and then it was
packaged. The transparent plastic frame is a 1x1 Feet square box, the LEDs for the four lanes are
centralized to ensure proper view by road users and the height of the pole is 8 inches and the
28

height of the vehicle used in this project is 5 inches to enable the road user to have a good view
of the traffic light. Also, the antenna of the RF receiver is placed on the outside of the casing to
ensure proper and increased distance of transmission, this is as shown in Fig. 4.2.

Figure 4.2: Picture of Casing

29

4.3

Testing
At the end of all the connection and soldering, the system began to display the light as expected
in the sequence of the traffic flow design starting with the North lane sequential lighting justify
the design and construction specification of this project.

4.4

Result and Discussion


At the course of the test the following result was obtained as displayed in table 4.1.
Table 4.1: Result of Traffic sequence without cars.

S/NO
1
2
3

LANE 1

LANE 2

LANE 3

PERIOD

RYG
100
100
100

RYG
100
1 00
100

RYG
100
100
100

5sec
5sec
5sec

Table 4.2: Result of traffic flow with cars on Lane 1.

S/NO
1
2
3
4
5
6

LANE 1

LANE 2

LANE 3

PERIOD

RYG
010
001
010
001
010
001

RYG
100
100
100
100
1 00
100

RYG
100
100
100
100
100
100

6sec
12sec
6sec
12sec
6sec
12sec

The result in Table 4.1 shows the summary of sequence flow and the duration in seconds for the
three lanes (lane 1, lane 2 and lane 3). R, Y and G denote the colours of the LEDs, which is,
Red, Yellow and Green.
30

Also, from the result obtained in table 4.2,after the first sequence which turns on all the red
lights for the three lanes for some specific time, it can be concluded that irrespective of the lane
on which traffic (cars) is present, the yellow LED is first of all activated for the lane which stays
on for some seconds then followed by the green light which remains on until the ultrasonic
sensor( receiver) stops sensing the presence of car.
Note: The traffic flow sequence of the presence of cars on lane 1 is also applied to the other two
lanes.
Table 4.3: Result of traffic flow with no cars on Lane 1.

S/NO
1
2

LANE 1

LANE 2

LANE 3

PERIOD

RYG
010
100

RYG
100
100

RYG
100
100

6sec
5ces

Thus, the project can be concluded to have worked according to specification as stated in the
design.
CHAPTER FIVE
CONCLUSION AND RECOMMENDATIONS
5.1

Introduction
The traffic flow was achieved by using Arduino UNO microcontroller. The use of
microcontroller to design the traffic control system was chosen because of its flexibility in terms
of programming and due to its effective economic value.

5.2

Conclusion

31

From the results obtained, it can be seen that after a lane is given the right of road, the other two
lanes are denied access of road so as to enable smooth traffic flow thereby minimizing
congestions on a lane at a time. It can be seen also that vehicles are given automatic right of road
whenever they meet the requirement.
Hence the objectives of this project has been satisfied in the sense that it reduces waiting time for
road users, serves as possible replacement to the use of traffic wardens, it also enhances a
satisfactory and high accuracy in traffic control on the roads, and of course the application of the
knowledge of microcontroller in controlling traffic light system.
5.3

Recommendations
This project like any other one has some limitations. One of the limitations is that the system
remains on a particular lane for as long as the lane is congested, regardless of the traffic situation
on the other lanes. It is recommended that any other person working on this kind of project
should work towards taking care of the problem.
If lane 1 becomes less congested, the traffic system moves to the lane 2 and after that, it returns
to lane 1 before going to lane 3. Lane 3 must have waited for a considerable number of time. It
is recommended that further work on this project should alter the code so that the traffic system
can turn directly from lane 2 to lane3.
Lastly, future work should concentrate on a design that could allocate time to the various lanes in
proportion to the traffic density and congestion.

32

REFERENCES
Adenote, A. (2012). Design and Construction of an Intelligent Traffic Control System for a TJunction, (Unpublished) HND Computer Engineering Project, College of Engineering,
School of Industrial Engineering, Kaduna Polytechnic, Kaduna, Nigeria.
Al-Khateeb, K. and Johari, J.A. Y. (2013). Intelligent Dynamic Traffic Light Sequence Using
RFID, Electrical and Computer Engineering Department, Faculty of Engineering,
International Islamic University Malaysia, Kuala Lumpur, Malaysia. Retrieved from:
www.irep.iium.edu.my/5732/1/Intelligent... [ 2013, April 5]
Dhar, A. (2008). Traffic and Road Condition Monitoring System, unpublished M. Tech. thesis,
Department of Computer Science and Engineering, Indian Institute of Technology,
Bombay Mumbai. India.

33

Goel, A., Ray, S. and Chandra, N. (2012). Intelligent Traffic Light System to Prioritized
Emergency Purpose Vehicles based on Wireless Sensor Network, International Journal
of
Computer Applications (0975 8887), 40 (12), 36-39
Kanojia,S. S. (2012). Real Time Traffic Light Control and Congestion Avoidance System,
International Journal of Engineering Research and Applications (IJERA), 2 (2),
925-929
Li, A.F. (2011). Self-Monitoring Traffic Light System for T-Junction or Multiple Junctions,
Bachelor of Electronic Engineering (Wireless Communication) thesis, Faculty of
Electronic and Computer Engineering, Universiti Teknikal Malaysia, Melaka. Malaysia.
Mbawike, N. (2007). 7 Million Vehicles Operate on Nigerian Roads-FRSC, Leadership,
November 16. Retrieved from: http://www.nigerianmuse.com/20071116004932zg/nmprojects/7-million-vehicles-operate-onnigerian-roads-frsc/[2013, April 3]
Osigwe, U. C., Oladipo, O. F. and Onibere, E. A. (2011). Design and Simulation of an Intelligent
Traffic Control System, International Journal of Advances in Engineering &
Technology, 1 (5), 47-57
Shilpa, S. C., Deshpande, R. S. and Rana, J. G. (2009). Design of Intelligent Traffic Light
Controller Using Embedded System,Second International Conference on Emerging
Trends in Engineering and Technology, ICETET-09, 1086-1091
Subramaniam, S. K., Esro, M. and Aw, F. L. (2012). Self-Algorithm Traffic Light Controllers for
Heavily Congested Urban Route, Wseas Transactions on Circuits and Systems, 11 (4),
115-124
Ugwu, C. (2009). Over 7 Million Vehicles Ply Nigerian Roads Daily-Filani, Daily Champion,
October 2. Retrieved from:http://allafrica.com/stories/200910020071.html[2013, April
3]

34

APPENDIX A
Sources Code
// traffic Robotic traffic control Project
// HC-SR04 Ping as car sensor:
// VCC to arduino 5v
// GND to arduino GND
//Echo to Arduino pin 7
// Trig to Arduino pin 8
// green light delay time depends on the distance the car is sensened, hence its poportional
35

#include <Servo.h>
//#define echoPin 7 // Echo Pin
//#define trigPin 8 // Trigger Pin
//#define LEDPin 13 // Onboard LED
Servo myservo; // create servo object to control a robot
// in the three directions
int pos = 90;

// variable to store the servo position

const int maxDeg = 180;


const int minDeg = 0;
const int echoPin = 7;
const int trigPin = 8;
const int led1Pin = 6; // stop indicator
const int led2Pin = 5; // warning indicator
const int led3Pin = 4; // go indicator
const int outputPin = 9; // pwm function will be disabled on pin 9 ato control servo
int maximumRange = 20; // Maximum range needed to pck up cars
int minimumRange = 0; // Minimum range needed to pck up cars
long duration, distance; // Duration used to calculate distance
void setup()
{
myservo.attach(outputPin); // attaches the servo on pin 9 to the servo object
pinMode(led1Pin, OUTPUT); // Use RED LED indicator (if required)
pinMode(led2Pin, OUTPUT); // Use YELLOW LED indicator (if required)
pinMode(led3Pin, OUTPUT); // Use GREEN LED indicator (if required)
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}
36

void loop()
{
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
//Calculate the distance (in cm) based on the speed of sound.
distance = duration/58.2;
//robot is at 180
if (distance >= maximumRange || distance <= minimumRange){
/* Send a negative number to ROBOT and Turn RED LED1 ON
to indicate "out of range" HENCE STOPE TRAFFIC*/
pos = 0;
digitalWrite(led1Pin, LOW);
digitalWrite(led2Pin, HIGH);
digitalWrite(led3Pin, LOW);
delay(1500);
digitalWrite(led1Pin, HIGH);
digitalWrite(led2Pin, LOW);
digitalWrite(led3Pin, LOW);
delay(5000);
digitalWrite(led1Pin, LOW);
digitalWrite(led2Pin, HIGH);
digitalWrite(led3Pin, LOW);
delay(1500);
37

myservo.write(pos);
delay(3000);
}
else {
/* Send the distance to the robot, and
turn red LED1 OFF to indicate successful reading and traffic should flow. */
digitalWrite(led1Pin, LOW);
digitalWrite(led2Pin, HIGH);
delay(1500);
digitalWrite(led2Pin, LOW);
digitalWrite(led3Pin, HIGH);
delay(1000*distance);
}
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
//Calculate the distance (in cm) based on the speed of sound.
distance = duration/58.2;
// robot is at 90
if (distance >= maximumRange || distance <= minimumRange){
/* Send a negative number to ROBOT and Turn RED LED1 ON
to indicate "out of range" HENCE STOPE TRAFFIC*/
pos = 90;
digitalWrite(led1Pin, LOW);
38

digitalWrite(led2Pin, HIGH);
digitalWrite(led3Pin, LOW);
delay(1500);
digitalWrite(led1Pin, HIGH);
digitalWrite(led2Pin, LOW);
digitalWrite(led3Pin, LOW);
delay(5000);
digitalWrite(led1Pin, LOW);
digitalWrite(led2Pin, HIGH);
digitalWrite(led3Pin, LOW);
delay(1500);
myservo.write(pos);
delay(3000);
}
else {
/* Send the distance to the robot, and
turn red LED1 OFF to indicate successful reading and traffic should flow. */
digitalWrite(led1Pin, LOW);
digitalWrite(led2Pin, HIGH);
delay(1500);
digitalWrite(led2Pin, LOW);
digitalWrite(led3Pin, HIGH);
delay(1000*distance);
}
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
39

delayMicroseconds(10);

digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
//Calculate the distance (in cm) based on the speed of sound.
distance = duration/58.2;
// robot is at 90
if (distance >= maximumRange || distance <= minimumRange){
/* Send a negative number to ROBOT and Turn RED LED1 ON
to indicate "out of range" HENCE STOPE TRAFFIC*/
pos = 180;
digitalWrite(led1Pin, LOW);
digitalWrite(led2Pin, HIGH);
digitalWrite(led3Pin, LOW);
delay(1500);
digitalWrite(led1Pin, HIGH);
digitalWrite(led2Pin, LOW);
digitalWrite(led3Pin, LOW);
delay(5000);
digitalWrite(led1Pin, LOW);
digitalWrite(led2Pin, HIGH);
digitalWrite(led3Pin, LOW);
delay(1500);
myservo.write(pos);
delay(3000);
}
else {
40

/* Send the distance to the robot, and


turn red LED1 OFF to indicate successful reading and traffic should flow. */
digitalWrite(led1Pin, LOW);
digitalWrite(led2Pin, HIGH);
delay(1500);
digitalWrite(led2Pin, LOW);
digitalWrite(led3Pin, HIGH);
delay(1000*distance);
}
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
//Calculate the distance (in cm) based on the speed of sound.
distance = duration/58.2;
// robot is at 90
if (distance >= maximumRange || distance <= minimumRange){
/* Send a negative number to ROBOT and Turn RED LED1 ON
to indicate "out of range" HENCE STOPE TRAFFIC*/
pos = 90;
digitalWrite(led1Pin, LOW);
digitalWrite(led2Pin, HIGH);
digitalWrite(led3Pin, LOW);
delay(1500);
digitalWrite(led1Pin, HIGH);
41

digitalWrite(led2Pin, LOW);
digitalWrite(led3Pin, LOW);
delay(5000);
digitalWrite(led1Pin, LOW);
digitalWrite(led2Pin, HIGH);
digitalWrite(led3Pin, LOW);
delay(1500);
myservo.write(pos);
delay(3000);
}
else {
/* Send the distance to the robot, and
turn red LED1 OFF to indicate successful reading and traffic should flow. */
digitalWrite(led1Pin, LOW);
digitalWrite(led2Pin, HIGH);
delay(1500);
digitalWrite(led2Pin, LOW);
digitalWrite(led3Pin, HIGH);
delay(1000*distance);
}
}

42

APPENDIX II

43

Das könnte Ihnen auch gefallen