from machine import Pin
from utime import sleep
led_green = Pin(2, Pin.OUT)
led_yellow = Pin(3, Pin.OUT)
led_red = Pin(4, Pin.OUT)
led_blue = Pin(10, Pin.OUT)
pb = Pin(20, Pin.IN, Pin.PULL_UP)
box = 0
bottle = 0
pause = False
def interup(Pin):
global pause
pause = True
pb.irq(trigger = Pin.IRQ_FALLING, handler= interup)
while True:
if pause:
#blink_led()
led_blue.on()
led_green.off()
sleep(1)
led_yellow.on()
print('steady ')
sleep(1)
led_yellow.off()
sleep(1)
led_red.on()
print('pedestrian...')
sleep(3)
led_red.off()
sleep(1)
led_yellow.on()
print('steady ')
sleep(1)
led_yellow.off()
sleep(1)
pause = False
else:
led_green.on()
print ('Vehicles moving..')
sleep(0.5)