from machine import Pin
from utime import sleep
led = Pin(10, Pin.OUT)
sw = Pin(21, Pin.IN, Pin.PULL_UP)
while True:
if sw.value() == 0:
led.value(1)
print(sw.value())
sleep(0.1)
else:
led.value(0)
print(sw.value())
sleep(0.1)
from machine import Pin
from utime import sleep
led = Pin(10, Pin.OUT)
sw = Pin(21, Pin.IN, Pin.PULL_UP)
while True:
if sw.value() == 0:
led.value(1)
print(sw.value())
sleep(0.1)
else:
led.value(0)
print(sw.value())
sleep(0.1)