from machine import Pin
from utime import sleep
led_pin = [Pin(2, Pin.OUT), Pin(3, Pin.OUT), Pin(4, Pin.OUT), Pin(5, Pin.OUT)]
messege = ['Vehicles moving', 'stedy', 'Pendestrian walk']
led_blue = Pin(10, Pin.OUT)
pb = Pin(20, Pin.IN, Pin.PULL_UP)
pause = False
def interup(Pin):
global pause
pause = True
pb.irq(trigger = Pin.IRQ_FALLING, handler= interup)
while True:
if pause:
led_blue.on()
for i in range (3):
led_pin[i-1].off()
led_pin[i].on()
print(messege[i])
sleep(1)
sleep(3)
for x in reversed (range(3)):
led_pin[x+1].off()
led_pin[x].on()
print(messege[x])
sleep(1)
pause = False
else:
led_pin[0].on()
led_blue.off()
print (messege[0])
sleep(0.5)
Loading
pi-pico-w
pi-pico-w