from machine import Pin
import time
led1 = Pin(15, Pin.OUT)
led2 = Pin(14, Pin.OUT)
led3 = Pin(13, Pin.OUT)
start_btn = Pin(16, Pin.IN, Pin.PULL_UP)
stop_btn = Pin(17, Pin.IN, Pin.PULL_UP)
running = False
def turn_off_all():
led1.off()
led2.off()
led3.off()
print("START = Click Green button \nSTOP = Press and hold Red button for a few secs")
while True:
if start_btn.value() == 0:
running = True
if stop_btn.value() == 0:
running = False
turn_off_all()
if running:
led1.toggle()
time.sleep(0.5)
if not running: continue
led2.toggle()
time.sleep(0.5)
if not running: continue
led3.toggle()
time.sleep(0.5)
else:
turn_off_all()