from machine import Pin
from time import sleep
# Wait for USB to become ready
sleep(0.1)
print("practice 1: smart Toggle started")
led = Pin(15, Pin.OUT)
button = Pin(16, Pin.IN, Pin.PULL_DOWN)
led = Pin(27, Pin.OUT)
button = Pin(7, Pin.IN, Pin.PULL_DOWN)
state = 0
while True:
if button.value() == 1:
state = not state
led.value(state)
print("LED state:", state)
sleep(0.3)
while button.value() == 1:
pass
sleep(0.05)