from machine import Pin
from time import ticks_ms,sleep_ms
led = Pin(2, Pin.OUT)
bot = Pin(27, Pin.IN)
b = bAnt = bot.value()
ativo = True
horaDaAventura = ticks_ms() + 500
while True:
b = bot.value()
if b != bAnt:
# Algo mudou
if b == 1:
ativo = not ativo
print ('oi')
sleep_ms(200)
print (b, bAnt)
bAnt = b
if ativo:
if ticks_ms() >= horaDaAventura:
led.value(not led.value())
horaDaAventura = ticks_ms() + 500