import micropython
from time import ticks_ms, ticks_diff
from machine import Pin
# Allocate emergency exception buffer
micropython.alloc_emergency_exception_buf(100)
# Define input pin as input with pull down (normally low)
comp_in = Pin(26, Pin.IN, Pin.PULL_DOWN)
# values to store output of ticks_ms for previous & current pulses
pre_peak = 0 # store previous curr_peak value
curr_peak = 0 # store output of ticks_ms at current interrupt
# flag to say interrupt has happened
interrupt_flag = False
# Interrupt callback
def ext_callback:
# Main code
while True:
try:
except KeyboardInterrupt:
break
print("Finished")