from machine import Pin
from utime import sleep
import _thread
led_red = Pin(15,Pin.OUT)
led_yellow = Pin(14,Pin.OUT)
led_green = Pin(13,Pin.OUT)
button = Pin(16, Pin.IN , Pin.PULL_UP)
buzzer = Pin(12, Pin.OUT)
global button_status
button_status = 0
def button_thread():
global button_status
while True:
if button.value() ==1:
button_status = 1
_thread.start_new_thread(button_thread, ())
while True:
if button_status ==1:
led_red.value(1)
for i in range(10):N
buzzer.value(1)
sleep(0.5)
buzzer.value(0)
sleep(0.5)
global button_status
button_status = 0
led_red.value(1)
sleep(5)
led_red.value(0)
led_yellow.value(1)
sleep(2)
led_yellow.value(0)
led_green.value(1)
sleep(5)
led_green.value(0)
led_yellow.value(1)
sleep(2)
led_yellow.value(0)