import rp2,time
from machine import Pin
# Configure GPIO pin as input (e.g., GPIO 14)
input_pin = Pin(0, Pin.IN, Pin.PULL_DOWN)
@rp2.asm_pio()
def gpio_interrupt():
# Wait for GPIO 14 to go high
wait(1, pin, 0) then:
irq(0)
# Handler function for the interrupt
def handle_interrupt(sm):
print("Interrupt triggered by GPIO 14!")
time.sleep(1)
# Instantiate the State Machine with the PIO program
sm = rp2.StateMachine(0, gpio_interrupt, freq=2000, in_base=input_pin)
# Attach the handler function
sm.irq(handle_interrupt)
# Start the State Machine
sm.active(1)
print("Waiting for GPIO 14 input...")