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

1

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 research’s 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

4

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

6 . The bigger vehicles were found on the road. 2. but replacing the PLC with a microcontroller because the PLC have the disadvantages of being bulky.algorithm programming. Hence this made the traffic control system efficient by taking the size of vehicle in to account. Depending upon the percentage of matching the timer for green and red light is controlled. the LDR will be replaced with an Ultrasonic sensor.3 Present Research Work The present research work will adopt different approaches from the reviewed works. 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. where object tracking was done on the bases of vehicle length in a video frame. a better performance could be obtained. After edge detection the matching is done on the bases of edges in the image with the reference image stored in the processor. Therefore. The approach of (Subramaniam et al.. 2012) will be adopted because of the self. The method used by Adenote. with these approaches combined. minimize traffic congestion and give consideration for the with more traffic.detection. 2009). This method will therefore reduce waiting time. expensive and are not easily adapted to high speed I/O while the microcontroller is less bulky and cheaper. will also be adopted. Using the embedded system. Here binary images with pixels detected are used by common operators Sobel and Laplace. Traffic congestion reduction can also be enhanced using the embedded system and GSM mobile phone (Shilpa et al. but in this case. They made the algorithm/technique which corrected the 97% truck count error and brought it down to 9%. the greater time was allotted to them for crossing the traffic light. They followed Video based Vehicle Detection and Classification (VVDC).. A very different system was built by Ryan and Guohui Zhang. (2012).

the main aim of this project is to design a directional movement of a robotic traffic control system. CHAPTER THREE DESIGN ANALYSIS 3. roundabouts and bypass does not detect congestion. This method is not just unsatisfactory but has limitations due to human nature such as fatigue and distraction resulting in control errors. space and congestion of vehicles. Using the human method of traffic control. the 7 . 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.2. The project has two major phases. such as the construction of ring roads.4 Comparative Analysis The old method of traffic control. 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 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.1 Introduction This chapter discusses the design of this project. the traffic warden’s life may be endangered because he has to stand in the middle of the road to carry out his duties.

Ultrasonic sensor LEDs Arduino UNO Microcontroller Resistor Capacitor All the above listed components will be integrated to form the complete prototype. iv.4 Design Analysis 8 . 3.3 Design Specification Input voltage = +5 V Operating voltage = 5 V Operating current = 310mA 3. iii. v. The hardware components are the backbone of the system. More detailed information of each component will be discussed in the following sections. This project was designed using 8051 microcontroller as the main component unit. 3. ii. 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.hardware design and the software implementation which is used to develop the control mechanism of the system.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.

1 Circuit Diagram of a traffic light control for a Robotic System 3. microcontroller (arduino) and the LEDs. It offers excellent range accuracy and stable readings in an easy-to-use package.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. It operation is not affected by sunlight or black material like Sharp rangefinders are (although 9 .5 HCSR04 Ultrasonic Sensor The HC-SR04 ultrasonic sensor uses sonar to determine distance to an object like bats or dolphins do. Figure 3.

then figure 3.3cm 8. plastic bottles. similar in performance to the SRF005 but with the low-price of a Sharp infrared sensor. Working Voltage: 5V (DC) 2. glass bottles. Sentry Angle : max 15 degree 6.2. such as transparent films.400cm 7. Working frequency: 40HZ 4.acoustically soft materials like cloth can be difficult to detect). shows the distance from the sensor to the point of intersection and the distance between that point and the sensor. Figure 3. Sentry Distance : 2cm . Echo signal : output TTL PWL signal 10. using Through-beam or Reflective Sensors.2. Ultrasonic waves are used to enable stable detection of transparent objects. The point of intersection of trigger ray and the ground can be calculated as follows: 10 .2: Ultrasonic Sensor The ultrasonic sensor has the following Specification: 1. High-accuracy : 0. Input trigger signal : 10us TTL impulse 9. The pictorial view of the ultrasonic sensor HCSR04 is reviewed in figure 3. Size : 45*20*15mm If the height of the ultra sonic sensor is place 43cm and it has sentry angle of 15 o. Working Current : max 15mA 3. Output Signal: 0-5V (Output high when obstacle in range) 5. and plate glass.

5cm But if the distance from the robot to that point of contact is x.965926 HYP = 44.3: Triangular Representation of The Sensor and The Point of Contact.6 LEDs (Output Interface Design) LEDs (Light Emitting Diodes) are electronic components that convert a portion of the current flowing through them into light. we could apply Pythagoras theorem of still trigonometrically ratio: Tan15= x 43 X= 43Tan15 X=11. To keep the current at or below the recommended operating current level.5cm 3. The intensity of the light produced vary with the current flowing. Applying trigonometrical ratios (SOHCAHTOA) Cos15= 43 cm HYP HYP = 43 cm cos 15 HYP = 43 cm 0. LEDs are 11 .15O 43cm Figure 3.

1) IZ R❑= 5−0. the output interface design is simply an LED display board with three different colors including RED.typically connected in series with a current limiting resistor.D5.D11 R4 12 . the value of resistor is determine by: R❑= V CC −V Z (3. Thus.The size of the resistor needed to limit the current through the LED to the desired value is calculated using Ohms law as follows. D1.D6 R2 D7. YELLOW and GREEN.D3 R1 D4.D8.6 10 ×10−3 R❑=440Ω . Fig.D10.D2. 3.D9 R3 D9.4 shows the arrangement of the LEDs in the output interface.

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.4: LED Output Interface 3. It is a smallest. It has everything that Diecimila/Duemilanove has (electrically) with more analog input pins and onboard +5V AREF jumper.Figure 3.0 of Arduino Software (IDE) were the reference versions of Arduino. past or outdated boards see the Arduino index of boards.8 Arduino UNO The Arduino UNO is a microcontroller board based on the ATmega328P. Base on the component requirements. It is a surface mount breadboard embedded version with integrated USB. 13 . for an extensive list of current. 2amperes has been provided. complete. The Uno board is the first in a series of USB Arduino boards. and the reference model for the Arduino platform.5 shows the pictorial diagram of Arduino UNO front and rear view. it is missing power jack. and breadboard friendly. Physically. The Uno board and version 1. "Uno" means one in Italian and was chosen to mark the release of Arduino Software (IDE) 1. now evolved to newer releases.0. Figure 3. 3. a 5volt.

5: Arduino UNO front view 3.Figure 3.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 .8.

8.EEPROM Clock Speed Dimension 3. and digitalRead() functions.73" x 1. 3. They operate at 5 volts.8.8. The power source is automatically selected to the highest voltage source.3 Memory: The ATmega168 has 16 KB of flash memory for storing code (of which 2 KB is 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).4 Input and Output Each of the 14 digital pins on the microcontroller can be used as an input or output. the 3. using pinMode().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. Each pin can 15 . the ATmega328 has 32 KB. 3. The FTDI FT232RL chip on the Nano is only powered if the board is being powered over USB. the ATmega328 has 2 KB of SRAM and 1 KB of EEPROM. or 5V regulated external power supply (pin 27).70" Power: The Arduino Nano can be powered via the Mini-B USB connection. 6-20V unregulated external power supply (pin 30). digitalWrite().2 1 KB (ATmega328P) 16 MHz 0. As a result. when running on external (non-USB) power. (also with 2 KB used for the bootloader).

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

The Arduino software includes a Wire library to simplify use of the I2C bus. The Arduino software includes a serial monitor which allows simple textual data to be sent to and from the Arduino board.5 button to shields which block the one on the board. To use the SPI communication. 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 . 3. Communication The Arduino UNO has a number of facilities for communicating with a computer. The ATmega168 and ATmega328 also support I2C (TWI) and SPI communication. which is available on digital pins 0 (RX) and 1 (TX).8. or Nano w/ ATmega168" or "Arduino Duemilanove or Nano w/ ATmega328" from the Tools > Board menu (according to the microcontroller on your board). Select "Arduino Diecimila. A Software Serial library allows for serial communication on any of the Nano's digital pins. please see the ATmega168 or ATmega328 datasheet. 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. or other microcontrollers. The ATmega168 and ATmega328 provide UART TTL (5V) serial communication. Reset: Bring this line LOW to reset the microcontroller. Typically used to add a reset 3.2. another Arduino. see the documentation for details. 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).6 Programming The Arduino UNO can be programmed with the Arduino software (download). For details. see the reference and tutorials.8. Duemilanove.

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

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

20 .3V pins bypasses the regulator. and digitlRead () functions.or the VIN pin of the board (7-12V). 3. using pinMode (). A maximum of 40mA is the value that must not be exceeded on any I/O pin to avoid permanent damage to the microcontroller. These pins are connected to the corresponding pins of the ATmega8U2 USB-to-TTL Serial chip. some pins have specialized functions: 1. GND: Ground pins. 5. 3V3: A 3.3V.3 volt supply generated by the on-board regulator. In addition. Input and Output Each of the 14 digital pins on the Uno can be used as an input or output. 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. IOREF: This pin on the Uno board provides the voltage reference with which the microcontroller operates. 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. 4. Supplying voltage via the 5V or 3. Maximum current draw is 50 mA. and can damage your board. Used to receive (RX) and transmit (TX) TTL serial data. Memory The ATmega328 has 32 KB (with 0. digitalWrite (). Serial: 0 (RX) and 1 (TX). They operate at 5 volts.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).

The ATmega328 provides UART TTL (5V) serial communication. 5. 6. or other microcontrollers. 6. These pins can be configured to trigger an interrupt on a low value. Used with analogReference(). PWM: 3. TWI: A4 or SDA pin and A5 or SCL pin.2. 9. Reference voltage for the analog inputs. Provide 8-bit PWM output with the analogWrite() function. which is available on digital pins 0 (RX) and 1 (TX). There is a built-in LED driven by digital pin 13. labelled A0 through A5. SPI: 10 (SS). 3. the LED is on. Reset. Bring this line LOW to reset the microcontroller. 2. External Interrupts: 2 and 3. The Uno has 6 analog inputs. 10. The 16U2 firmware uses the standard USB COM drivers. 5. 1024 different values).9 Serial Communication The Uno has a number of facilities for communicating with a computer. 21 . When the pin is HIGH value. LED: 13. These pins support SPI communication using the SPI library. However. Typically used to add a reset button to shields which block the one on the board. another Uno board. and no external driver is needed. Support TWI communication using the Wire library. See the attachInterrupt() function for details. it's off. An ATmega16U2 on the board channels this serial communication over USB and appears as a virtual com port to software on the computer. By default they measure from ground to 5volts There are a couple of other pins on the board: 1. each of which provide 10 bits of resolution (i. 11 (MOSI). 13 (SCK). AREF. or a change in value. and 11.e. 12 (MISO). 3. 4.8. when the pin is LOW. a rising or falling edge.

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

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

The pads on either side of the trace can be soldered together to re-enable it. In the table of traffic. the operating sequence table is developed as in Table 3. It's labelled "RESET-EN". Table 3. 24 .The Uno board contains a trace that can be cut to disable the auto-reset. ‘Go’ is represented by logic ‘1’ and Stop is represented by logic ‘0’. Based on this information. the GO signal is indicated by a green light. In the high way code.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. 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.9 Operating Sequence The sequences by which the traffic flow signal will be operated is shown in Table 3. 3.1.1. You may also be able to disable the auto-reset by connecting a 110 ohm resistor from 5V to the reset line.

6 shows the flow chart for all the lanes. lane 2 to lane 1 then to the lane 3. and then it turns ON the LEDs CARS flow AVAILABLE ONofLANE 2? shown in Table 3.START 3.11.1.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.1 Flow Chart ON GREEN AND DELAY TheTURN program starts by first of all initializing the sensors. After according to demand based on the traffic sequences operation TURN ON RED LIGHT AND DELAY that. a set of instructions (programs) was developed to TURN ON RED LIGHT AND DELAY aid the hardware to perform the required task. 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 . 3. The operation is interrupted only by presence of cars as follows: TURN ON YELLOW AND DELAY CHECK NEXT LANE 3. it goes to the next lane. The software was developed using C programming language. Figure 3. The detail of the source code is as shown in appendix I.10 Software Design POWER ON With the hardware implementation completed.

the precautions taken before soldering. 4. a transparent plastic frame to house the electronic components.CHAPTER FOUR CONSTRUCTION.1 Introduction This chapter contains the construction work in detail. and the entire layout in order to secure the components 26 . it also contain the result analysis. Vero board.2 Construction The basic materials needed for this project were bread board. TESTING AND RESULT 4.

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

2 Packaging This project prototype was packaged in a transparent plastic frame in order to enhance visibility. Thus. The LEDs were positioned at the appropriate location to stimulate proper traffic control.2. protect the components and layout from dust. The transparent plastic frame is a 1x1 Feet square box. The soldering was cleaned and tested with caution to have a good work and then it was packaged. and of course to make it look attractive. 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 .1: Picture of Soldered Components 4. the construction has been carried out in proper way to ensure we have the expected result.Figure 4.

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. this is as shown in Fig. the antenna of the RF receiver is placed on the outside of the casing to ensure proper and increased distance of transmission. Figure 4.2. 4.2: Picture of Casing 29 . Also.

4.4 Result and Discussion At the course of the test the following result was obtained as displayed in table 4. Yellow and Green. Red. which is. lane 2 and lane 3).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.3 Testing At the end of all the connection and soldering.4. R. 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. Y and G denote the colours of the LEDs.2: Result of traffic flow with cars on Lane 1. 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.1: Result of Traffic sequence without cars. Table 4.1 shows the summary of sequence flow and the duration in seconds for the three lanes (lane 1. 30 .

the project can be concluded to have worked according to specification as stated in the design. it can be concluded that irrespective of the lane on which traffic (cars) is present.2. from the result obtained in table 4. 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.3: Result of traffic flow with no cars on Lane 1. 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.after the first sequence which turns on all the red lights for the three lanes for some specific time. Table 4. S/NO 1 2 LANE 1 LANE 2 LANE 3 PERIOD RYG 010 100 RYG 100 100 RYG 100 100 6sec 5ces Thus. 5.2 Conclusion 31 . CHAPTER FIVE CONCLUSION AND RECOMMENDATIONS 5.Also.1 Introduction The traffic flow was achieved by using Arduino UNO microcontroller. Note: The traffic flow sequence of the presence of cars on lane 1 is also applied to the other two lanes.

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. Hence the objectives of this project has been satisfied in the sense that it reduces waiting time for road users. 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. One of the limitations is that the system remains on a particular lane for as long as the lane is congested. 32 . it returns to lane 1 before going to lane 3.From the results obtained. Lane 3 must have waited for a considerable number of time. regardless of the traffic situation on the other lanes. 5. the traffic system moves to the lane 2 and after that. It is recommended that any other person working on this kind of project should work towards taking care of the problem. Lastly.3 Recommendations This project like any other one has some limitations. It can be seen also that vehicles are given automatic right of road whenever they meet the requirement. serves as possible replacement to the use of traffic wardens. If lane 1 becomes less congested. 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. future work should concentrate on a design that could allocate time to the various lanes in proportion to the traffic density and congestion.

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

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

hence its poportional 35 .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.

// go indicator const int outputPin = 9. pinMode(echoPin. } 36 . // Use RED LED indicator (if required) pinMode(led2Pin.attach(outputPin). OUTPUT). // variable to store the servo position const int maxDeg = 180. // attaches the servo on pin 9 to the servo object pinMode(led1Pin. // Use YELLOW LED indicator (if required) pinMode(led3Pin.h> //#define echoPin 7 // Echo Pin //#define trigPin 8 // Trigger Pin //#define LEDPin 13 // Onboard LED Servo myservo. OUTPUT). // warning indicator const int led3Pin = 4. // stop indicator const int led2Pin = 5. INPUT). // Duration used to calculate distance void setup() { myservo. OUTPUT). // pwm function will be disabled on pin 9 ato control servo int maximumRange = 20. // Minimum range needed to pck up cars long duration. OUTPUT). const int minDeg = 0. const int trigPin = 8. const int echoPin = 7. // Maximum range needed to pck up cars int minimumRange = 0. // create servo object to control a robot // in the three directions int pos = 90. const int led1Pin = 6. distance. // Use GREEN LED indicator (if required) pinMode(trigPin.#include <Servo.

HIGH). delayMicroseconds(10). delay(5000). digitalWrite(led1Pin. //Calculate the distance (in cm) based on the speed of sound. delay(1500). LOW). LOW). HIGH). distance = duration/58. digitalWrite(led2Pin. digitalWrite(trigPin. duration = pulseIn(echoPin. digitalWrite(trigPin. LOW). digitalWrite(led2Pin. HIGH). LOW).2. digitalWrite(led3Pin. digitalWrite(led3Pin. digitalWrite(led1Pin. digitalWrite(led3Pin.void loop() { digitalWrite(trigPin. delayMicroseconds(2). digitalWrite(led2Pin. delay(1500). LOW). LOW). HIGH). LOW). LOW). //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. HIGH). 37 .

HIGH). LOW).2. HIGH). */ digitalWrite(led1Pin. } else { /* Send the distance to the robot. duration = pulseIn(echoPin. delay(1000*distance). } digitalWrite(trigPin. 38 . LOW). LOW). distance = duration/58. HIGH). HIGH). digitalWrite(trigPin. //Calculate the distance (in cm) based on the speed of sound. digitalWrite(led2Pin. and turn red LED1 OFF to indicate successful reading and traffic should flow. delayMicroseconds(2). digitalWrite(led3Pin. LOW).myservo. digitalWrite(trigPin. LOW).write(pos). delayMicroseconds(10). delay(1500). digitalWrite(led2Pin. digitalWrite(led1Pin. // 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. delay(3000).

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

LOW). LOW). duration = pulseIn(echoPin. distance = duration/58. digitalWrite(led1Pin. LOW).write(pos). delay(1500). digitalWrite(led3Pin. digitalWrite(led1Pin. LOW). digitalWrite(led1Pin.2. HIGH). myservo. LOW). delay(1500). digitalWrite(led3Pin. digitalWrite(led2Pin. digitalWrite(led3Pin. LOW).delayMicroseconds(10). digitalWrite(trigPin. digitalWrite(led2Pin. delay(5000). // 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(led2Pin. } else { 40 . HIGH). HIGH). LOW). HIGH). //Calculate the distance (in cm) based on the speed of sound. delay(3000).

HIGH). */ digitalWrite(led1Pin. digitalWrite(led2Pin. and turn red LED1 OFF to indicate successful reading and traffic should flow. } digitalWrite(trigPin. HIGH). 41 . delayMicroseconds(2). digitalWrite(trigPin. duration = pulseIn(echoPin.2. LOW). digitalWrite(led1Pin. delay(1500). //Calculate the distance (in cm) based on the speed of sound. LOW). HIGH). digitalWrite(led2Pin. distance = duration/58. HIGH). digitalWrite(led3Pin./* Send the distance to the robot. LOW). HIGH). delayMicroseconds(10). LOW). digitalWrite(led1Pin. LOW). digitalWrite(trigPin. LOW). // 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. delay(1500). digitalWrite(led2Pin. delay(1000*distance). HIGH). digitalWrite(led3Pin.

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

APPENDIX II 43 .