from machine import Pin
from utime import sleep
button_pin = Pin(26, Pin.IN, Pin.PULL_UP)
def reset_on_button_press(pin):
print("Reset button pressed! Resetting...")
'''
In a computer, an interrupt request (or IRQ) is a hardware signal sent to the
processor that temporarily stops a running program and allows a special program, an
interrupt handler, to run instead.
'''
# Attach the interrupt to the button pin
button_pin.irq(trigger=Pin.IRQ_FALLING, handler=reset_on_button_press)
while True:
sleep(1)