Introduction
Traffic signals or traffic alerts is used to regulate the traffic and supervised motorist and pedestrians. The equipment and lighting alternate accorded to users by showing "green" for go, "yellow" transmission that the light changes to red and "red" for stop. Without traffic lights there will be a great deal of road injuries and traffic congestion. This experiment shows how traffic lamps work using Arduino.
Materials with Description
- 5 MM LED (5)
Used as an result in the circuit and to know if the code is working.
- Resistor (220 ohms) (6)
An electronic device used to regulate the existing in the circuit.
- Jumper Cables M/M (13)
Used as the connector to different pins in the prototyping panel.
- USB wire (1)
Used as the connector from computer to DFRArduino Uno R3.
- DFRArduino Uno R3 (1)
A programmable circuit table. This hardware reads the code published in the computer.
- Computer (1)
Used to write, compile and upload the code to the circuit.
Procedure (self-explained)
- Place the LEDs to the plank. Traffic lighting 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 lamps for motorist, green(2) positive pin at pin J8 and negative pin to pin J7, yellowish 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. Storyline the force button switcher at pin E10, E12, F10 and F12.
- 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
- Connect the jumper cables, line(1) from A2 to DP 12, line(2) from A5 to DP 11, wire(3) from A7 to GND, wire(4) from A8 to DP 10, cable(5) from A10 to DP 9, cable(6) from A14 to DP 8, line(7) from A17 to DP7, cable(8) from C12 to PP 5V, line(9) from I1 to I4, cable(10) from H4 to H7, cable(11) from I7 to I13, wire(12) from H13 to H16, and cable(13) from I16 to GND.
6. Hook up the USB wire to the computer and the circuit, compile the code then upload.
Circuit Diagram
Code
Code Research
""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 linked to the Arduino.
"int pedRed = 8;, int pedGreen = 7;" the initialization of pins for pedestrian lights.
"int crossTime = 5000;" units 5 seconds for the pedestrian Resulted in lit.
"pinMode(pinType, OUTPUT);" pinType models what pin to make use of, LEDs in this circuit provides as output.
"pinMode(button, INPUT);" the suggestions in the circuit came from the push button switcher.
"int point out = digitalRead(button);" reads if the press button switcher is forced/pressed or not.
"if (state == HIGH) && (millis() - changeTime) > 5000)" a problem that checks if the thrust button switchern was pressed 5 seconds and then call the technique changeLights().
"void changeLights()" in this technique, this implies the sequence signals when it will lit and shows how car/motorist and pedestrian traffic lights work.
"delay(2000);" delays for 2 mere seconds before it the green light changes to yellow light and "delay(1000);" hold off for a second before it will go red.
"changeTime = millis();" this stores the existing time in milliseconds to changeTime by getting in touch with millis().
Comparison of Code vs. Hardware Output
The code manipulate, manages and provides the productivity for the hardware. Within this experiment if you drive or press the push button switcher it changes its lights in a of placed time and this shows how traffic equipment and lighting works.
Recommendation/Enhancement
We may use this traffic light test to create minuscule traffic lights inside the car or motor. In that case the motorist further on the traffic light will also know the transmission.