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
  1. Raspberry Pi
  2. LED's
  3. Push Button
  4. Bread Board
  5. Hook up Wires
Traffic Lights
  1. 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.
  2. The signaling devices are positioned at the road intersections, pedestrian crossings, and other locations to control the flow of traffic.
  3. 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.
  4. 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.
    IoT
Traffic Signal Timing
  1. Traffic signal timing is the technique where the traffic engineers are required to determine who has the right-of-way at an intersection.
  2. 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
  1. Led1:GPIO11
  2. Led2:GPIO12
  3. Led3:GPIO13
  4. Connect all the negative pins to the GND.
  5. Connect the SD Card with the OS and the data cable.
Programming
  1. # import time and gpio modules
  2. import time
  3. import RPi.GPIO as GPIO
  4. # set pin 11, 12 and 13 as an outputs
  5. GPIO.setup(11, GPIO.OUT)# red light
  6. GPIO.setup(12, GPIO.OUT)# amber light
  7. GPIO.setup(13, GPIO.OUT)# green light
  8. # set pin 15 as our input
  9. GPIO.setup(15, GPIO.IN)# push button
  10. # set counters at zero
  11. carA = 0
  12. flashA = 0
  13. # set up a while loop so the program will keep repeating itself indefinitely
  14. while True: #call pin 15 button
  15. button = GPIO.input(15)# if button is pressed set carA as 1
  16. if button == False:
  17. carA = 1
  18. #if no car detected turn off green and amber lights and
  19. # turn on red light
  20. if carA == 0:
  21. GPIO.output(11, True)
  22. GPIO.output(12, False)
  23. GPIO.output(13, False)
  24. #if car detected then run through sequence
  25. if carA == 1: #amber light on
  26. GPIO.output(12, True)# wait 5 seconds
  27. time.sleep(5)# turn off red and amber lights
  28. GPIO.output(11, False)
  29. GPIO.output(12, False)# turn on green light
  30. GPIO.output(13, True)# wait 5 second
  31. time.sleep(5)# turn off green light
  32. GPIO.output(13, False)# set while loop to flash amber light 5 times
  33. while flashA < 5: #on, wait 5 seconds
  34. GPIO.output(12, True)
  35. time.sleep(.5)# off wait 5 seconds
  36. GPIO.output(12, False)
  37. time.sleep(.5)# add one to the flash counter
  38. flashA = flashA + 1# reset flash counter
  39. flashA = 0# reset carA
  40. carA = 0
Explanation
  1. In this blog, I have explained about the traffic signal by the correct delay time.
  2. The output will be set as the GPIO pin and connect the push button to turnoff all the LEDs when not in use.
  3. 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.
Output
IoT