# กำหนดพินสำหรับไฟแดง ไฟเหลือง และไฟเขียว
from machine import Pin
import time
red_W=Pin(4,Pin.OUT)
yellow_W=Pin(0,Pin.OUT)
green_W=Pin(2,Pin.OUT)
red_N=Pin(23,Pin.OUT)
yellow_N=Pin(22,Pin.OUT)
green_N=Pin(21,Pin.OUT)
red_E=Pin(19,Pin.OUT)
yellow_E=Pin(18,Pin.OUT)
green_E=Pin(17,Pin.OUT)
red_S=Pin(25,Pin.OUT)
yellow_S=Pin(26,Pin.OUT)
green_S=Pin(27,Pin.OUT)
def North_light():
red_S.on()
red_E.on()
red_W.on()
green_N.on()
time.sleep(5)
green_N.off()
yellow_N.on()
time.sleep(2)
yellow_N.off()
red_S.off()
red_E.off()
red_W.off()
def South_light():
red_N.on()
red_E.on()
red_W.on()
green_S.on()
time.sleep(5)
green_S.off()
yellow_S.on()
time.sleep(2)
yellow_S.off()
red_N.off()
red_E.off()
red_W.off()
def East_light():
red_N.on()
red_S.on()
red_W.on()
green_E.on()
time.sleep(5)
green_E.off()
yellow_E.on()
time.sleep(2)
yellow_E.off()
red_N.off()
red_S.off()
red_W.off()
def West_light():
red_N.on()
red_E.on()
red_S.on()
green_W.on()
time.sleep(5)
green_W.off()
yellow_W.on()
time.sleep(2)
yellow_W.off()
red_N.off()
red_E.off()
red_S.off()
while True:
South_light()
North_light()
East_light()
West_light()