from machine import Pin
import time
# Lane 1 Pins
lane1_red = Pin(19, Pin.OUT)
lane1_yel = Pin(18, Pin.OUT)
lane1_gre = Pin(5, Pin.OUT)
# Lane 2 Pins
lane2_red = Pin(17, Pin.OUT)
lane2_yel = Pin(16, Pin.OUT)
lane2_gre = Pin(4, Pin.OUT)
# Some constant time delays (Change these to change the delay of blinking of the LEDs)
main_delay = 3 # seconds
yell_delay = 2 # seconds
while True:
# Simulating the traffic flow for lane 2
lane1_red.on()
lane2_gre.on()
time.sleep(main_delay)
lane1_red.off()
lane2_gre.off()
# Simulating the effect of yellow light on both lanes
lane2_yel.on()
time.sleep(yell_delay)
lane2_yel.off()
# Simulating the traffic flow for lane 1
lane1_gre.on()
lane2_red.on()
time.sleep(main_delay)
lane1_gre.off()
lane2_red.off()
# Simulating the effect of yellow light on both lanes
lane1_yel.on()
lane2_yel.on()
time.sleep(yell_delay)
lane1_yel.off()
lane2_yel.off()