#
# MicroPython for the IoT
# Example 3 - Interrupt Flash LEDs
#
from machine import Pin # Pin class
from utime import sleep # sleep method
# LED verde
led = Pin(15,Pin.OUT)
# Botão
button = Pin(13, Pin.IN, Pin.PULL_DOWN)
led.off()
# Função callback acessada pelo Botão
# por meio de interrupção
def flash_led(not_used):
for i in range(0, 5):
led.on()
sleep(0.5)
led.off()
sleep(1)
# Ativa a função para a interrupção
button.irq(trigger=Pin.IRQ_FALLING, handler=flash_led)
print("Pronto para o teste!")
while True:
sleep(0.25)
Loading
pi-pico-w
pi-pico-w