#Script for a functional traffic light system.
from machine import Pin
import time
led0=Pin(13, Pin.OUT)
led1=Pin(14, Pin.OUT)
led2=Pin(15, Pin.OUT)
led3=Pin(16, Pin.OUT)
led4=Pin(17, Pin.OUT)
led5=Pin(18, Pin.OUT)
while True:
# first loop
led3.value(1) #horizontal red light
led0.value(1) #vertical red light
time.sleep(5)
led0.value(0)
led1.value(1) #vertical yellow light
time.sleep(5)
led1.value(0)
led2.value(1) #vertical green light
time.sleep(5)
led2.value(0)
#reverse start from here, for first loop
led1.value(1) #vertical yellow light
time.sleep(5)
led1.value(0)
#second loop
led0.value(1) #vertical red light
led3.value(1) #horizontal red light
time.sleep(5)
led3.value(0)
led4.value(1) #horizontal yellow light
time.sleep(5)
led4.value(0)
led5.value(1) #horizontal green light
time.sleep(5)
led5.value(0)
#reverse starts from here, for second loop
led4.value(1) #horizontal yellow light
time.sleep(5)
led4.value(0)