Creation of Traffic Light Circuit

Modified: 7th Aug 2017
Wordcount: 859 words

Disclaimer: This is an example of a student written essay. Click here for sample essays written by our professional writers.
Any opinions, findings, conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the views of UKEssays.ae.

Cite This

 

Introduction

Traffic lights or traffic signals is used to control the traffic and to supervised motorist and pedestrians. The lights alternate accorded to users by displaying “green” for go, “yellow” signal that the light will change to red and “red” for stop. Without traffic lights there will be a lot of road accidents and traffic congestion. This experiment shows how traffic lights work using Arduino.

Materials with Description

  1. 5 MM LED (5)

Used as an output in the circuit and to know if the code is working.

  1. Resistor (220 ohms) (6)

An electronic device used to control the current in the circuit.

  1. Jumper Wires M/M (13)

Used as the connector to different pins in the prototyping board.

  1. USB cable (1)

Used as the connector from computer to DFRArduino Uno R3.

  1. DFRArduino Uno R3 (1)

A programmable circuit board. This hardware reads the code uploaded in the computer.

  1. Computer (1)

Used to write, compile and upload the code to the circuit.

Procedure (self-explained)

  1. Place the LEDs to the board. Traffic lights for pedestrians, green(1) positive pin at pin J17 and negative pin to pin J16, red(1) positive pin at pin J14 and negative pin to pin J13.

2.Traffic lights for motorist, green(2) positive pin at pin J8 and negative pin to pin J7, yellow positive pin at pin J5 and negative pin to pin J4. red(2) positive pin at pin J2 and negative pin to pin J1.

3. Plot the push button switcher at pin E10,E12, F10 and F12.

  1. Place the resistor(1) from D2 to G2, resistor(2) from D5 to G5, resistor(3) from D8 to G8, resistor(4) from D14 to G14, resistor(5) from D17 to G17, resistor(6) from C7 to C10
  1. Connect the jumper wires, wire(1) from A2 to DP 12, wire(2) from A5 to DP 11, wire(3) from A7 to GND, wire(4) from A8 to DP 10, wire(5) from A10 to DP 9, wire(6) from A14 to DP 8, wire(7) from A17 to DP7, wire(8) from C12 to PP 5V, wire(9) from I1 to I4, wire(10) from H4 to H7, wire(11) from I7 to I13, wire(12) from H13 to H16, and wire(13) from I16 to GND.

6. Connect the USB cable to the computer and the circuit, compile the code then upload.

Circuit Diagram

D:My DocumentsnikkoCS324L Robotics (Lab)imagesexpimg003.jpg

Code

D:nikkoCABANGDB2DesktopTemproboexp3imagescodeexp3.png

D:nikkoCABANGDB2DesktopTemproboexp3imagescodeexp3.png

Code Analysis

“”int carRed = 12;, int carYellow = 11;, int carGreen = 10;” this is the initialization of pins for motorists traffic lights.

“int button = 9;” the initialization of the pushbutton connected to the Arduino.

“int pedRed = 8;, int pedGreen = 7;” the initialization of pins for pedestrian lights.

“int crossTime = 5000;” sets 5 seconds for the pedestrian LED to lit.

“pinMode(pinType,OUTPUT);” pinType sets what pin to use, LEDs in this circuit serves as output.

“pinMode(button, INPUT);” the input in the circuit came from the push button switcher.

“int state = digitalRead(button);” reads if the push button switcher is pushed/pressed or not.

“if (state == HIGH) && (millis() – changeTime) > 5000){…}” a condition that checks if the push button switchern was pressed 5 seconds and then call the method changeLights().

“void changeLights(){…}” in this method, it indicates the sequence lights when it will lit and shows how car/motorist and pedestrian traffic lights work.

“delay(2000);” delays for 2 seconds before it the green light changes to yellow light and “delay(1000);” delay for a second before it goes red.

“changeTime = millis();” this stores the current time in milliseconds to changeTime by calling millis().

Comparison of Code vs. Hardware Output

The code manipulate, manages and provides the output for the hardware. In this experiment if you push or press the push button switcher it changes its lights in a of set time and this shows how traffic lights works.

Recommendation/Enhancement

We can use this traffic light experiment to create mini traffic lights inside the car or motor. In that case the motorist farther on the traffic light will also know the signal.

 

Cite This Work

To export a reference to this article please select a referencing style below:

Give Yourself The Academic Edge Today

  • On-time delivery or your money back
  • A fully qualified writer in your subject
  • In-depth proofreading by our Quality Control Team
  • 100% confidentiality, the work is never re-sold or published
  • Standard 7-day amendment period
  • A paper written to the standard ordered
  • A detailed plagiarism report
  • A comprehensive quality report
Discover more about our
Essay Writing Service

Essay Writing
Service

AED558.00

Approximate costs for Undergraduate 2:2

1000 words

7 day delivery

Order An Essay Today

Delivered on-time or your money back

Reviews.io logo

1858 reviews

Get Academic Help Today!

Encrypted with a 256-bit secure payment provider