Introduction
In this blog, I am going to explain about the Traffic Light Signal With Raspberry Pi. It will see the time delay in the light and it will see it as the traffic light. I have made a little program to run some LEDs via the GPIO triggered by a push button to do a traffic light sequence.
Parts Of Lists
- Raspberry Pi
- LED's
- Push Button
- Bread Board
- Hook up Wires
Traffic Lights
- Traffic lights, also known as traffic signals, traffic lamps, traffic semaphore, signal lights, stop lights, robots (in South Africa) and (in technical parlance) traffic control signals.
- The signaling devices are positioned at the road intersections, pedestrian crossings, and other locations to control the flow of traffic.
- The world's first, manually operated gas-lit traffic signal was short-lived. Installed in London in December 1868, it exploded less than a month later, injuring or killing its policeman operator.
- Traffic control started to seem necessary in the late 1890s and Earnest Sirrine from Chicago patented the first automated traffic control system in 1910. It used the words "STOP" and "PROCEED", although neither word lit up.
Traffic Signal Timing
- Traffic signal timing is the technique where the traffic engineers are required to determine who has the right-of-way at an intersection.
- Signal timing involves deciding how much green time the traffic lights shall provide at an intersection approach, how long the pedestrian WALK signal should be and many other numerous factors.
Connection for Traffic signal
Take the 3 LEDs for the experiment
- Led1:GPIO11
- Led2:GPIO12
- Led3:GPIO13
- Connect all the negative pins to the GND.
- Connect the SD Card with the OS and the data cable.
Programming
-
- import time
- import RPi.GPIO as GPIO
-
-
-
- GPIO.setup(11, GPIO.OUT)
- GPIO.setup(12, GPIO.OUT)
- GPIO.setup(13, GPIO.OUT)
-
-
- GPIO.setup(15, GPIO.IN)
-
-
- carA = 0
- flashA = 0
-
-
- while True:
- button = GPIO.input(15)
- if button == False:
- carA = 1
-
-
-
- if carA == 0:
- GPIO.output(11, True)
- GPIO.output(12, False)
- GPIO.output(13, False)
-
-
- if carA == 1:
- GPIO.output(12, True)
- time.sleep(5)
- GPIO.output(11, False)
- GPIO.output(12, False)
- GPIO.output(13, True)
- time.sleep(5)
- GPIO.output(13, False)
-
- while flashA < 5:
- GPIO.output(12, True)
- time.sleep(.5)
- GPIO.output(12, False)
- time.sleep(.5)
- flashA = flashA + 1
- flashA = 0
- carA = 0
Explanation
- In this blog, I have explained about the traffic signal by the correct delay time.
- The output will be set as the GPIO pin and connect the push button to turnoff all the LEDs when not in use.
- The traffic signal is very useful for the real-time. The operation of traffic signals is currently limited by the data available from traditional point sensors. Point detectors can provide only limited vehicle information at a fixed location.