# four way traffic light system (two way route)
from machine import Pin
import time
red1 = Pin(2, Pin.OUT)
yellow1 = Pin(14, Pin.OUT)
green1 = Pin(12, Pin.OUT)
red2 = Pin(5, Pin.OUT)
yellow2 = Pin(4, Pin.OUT)
green2 = Pin(0, Pin.OUT)
red3 = Pin(13, Pin.OUT)
yellow3 = Pin(15, Pin.OUT)
green3 = Pin(32, Pin.OUT)
red4 = Pin(16, Pin.OUT)
yellow4 = Pin(27, Pin.OUT)
green4 = Pin(25, Pin.OUT)
while True:
red1.on()
red3.on()
green2.on()
green4.on()
time.sleep(5)
red1.off()
red3.off()
green2.off()
green4.off()
yellow1.on()
yellow3.on()
yellow2.on()
yellow4.on()
time.sleep(1)
yellow1.off()
yellow3.off()
yellow2.off()
yellow4.off()
green1.on()
green3.on()
red2.on()
red4.on()
time.sleep(5)
red2.off()
red4.off()
green1.off()
green3.off()
yellow1.on()
yellow3.on()
yellow2.on()
yellow4.on()
time.sleep(1)
yellow1.off()
yellow3.off()
yellow2.off()
yellow4.off()