from machine import Pin # Interrupt_Edge.py # Use a falling-edge interrupt to count # number of button pushes interrupt_flag=0 N = 0 pin = Pin(15,Pin.IN,Pin.PULL_UP) def callback(pin): global interrupt_flag global N interrupt_flag=1 N = N + 1 # options are RISING, FALLING, LOW_LEVEL, HIGH_LEVEL pin.irq(trigger=Pin.IRQ_FALLING, handler=callback) while True: if interrupt_flag is 1: print("Interrupt # ", N) interrupt_flag=0