from machine import Pin
from time import sleep
led_vang = Pin(27, Pin.OUT)
led_tim = Pin(14, Pin.OUT)
led_hong = Pin(12, Pin.OUT)
led_xanh = Pin(13, Pin.OUT)
ds = [led_vang,led_tim,led_hong,led_xanh]
t1 = 0.5
t2 = 0.5
t3 = 0.5
t4 = 0.5
nut_1 = Pin(23, Pin.IN, Pin.PULL_UP)
nut_2 = Pin(21, Pin.IN, Pin.PULL_UP)
nut_3 = Pin(5, Pin.IN, Pin.PULL_UP)
nut_4 = Pin(4, Pin.IN, Pin.PULL_UP)
while True:
buttonStatus1 = nut_1.value()
buttonStatus2 = nut_2.value()
buttonStatus3 = nut_3.value()
buttonStatus4 = nut_4.value()
if buttonStatus1==0:
for i in range(0,4,1):
ds[i].value(1)
sleep(t1)
for i in range(0,4,1):
ds[i].value(0)
sleep(t1)
if buttonStatus2==0:
for i in range(3,-1,-1):
ds[i].value(1)
sleep(t2)
for i in range(3,-1,-1):
ds[i].value(0)
sleep(t2)
if buttonStatus3==0:
for i in range(0,4,2):
ds[i].value(1)
sleep(t3)
for i in range(1,5,2):
ds[i].value(1)
sleep(t3)
for i in range(0,4,2):
ds[i].value(0)
for i in range(1,5,2):
ds[i].value(0)
sleep(t3)
if buttonStatus4==0:
for i in range(1,5,2):
ds[i].value(1)
sleep(t4)
for i in range(0,4,2):
ds[i].value(1)
sleep(t4)
for i in range(1,5,2):
ds[i].value(0)
sleep(t4)
for i in range(0,4,2):
ds[i].value(0)
sleep(t4)