from machine import Pin
from time import sleep
sleep(0.1)
print("Practice 1 ready: smart toggle started.")
led = Pin(15, Pin.OUT)
led1 = Pin(14,Pin.OUT)
button1 = Pin(16, Pin.IN, Pin.PULL_DOWN)
button2 = Pin(13, Pin.IN, Pin.PULL_DOWN)
state = 0
while True:
if button1.value() == 1:
state = not state # toggle between 0 and 1
led.value(state)
print("LED state:", state)
elif button2.value() == 1:
state = not state # toggle between 0 and 1
led1.value(state)
print("LED1 state:", state)
sleep(0.05)