from machine import Pin
from time import sleep
sleep(0.1)
print("Practice 1: Smart Toggle Started")
led = Pin(3, Pin.OUT)
button = Pin(16, Pin.IN, Pin.PULL_DOWN)
led = Pin(5, Pin.OUT)
button = Pin(15, Pin.IN, Pin.PULL_DOWN)
led = Pin(15, Pin.OUT)
button = Pin(4, 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)