# Test interrupts # 9/Oct 2022 J Fisher #### imports from machine import Pin import time, utime from UKMARS import * stp = Pin(28, Pin.IN) # set up stop sensor input as digital not analogue Markers = 0 ssense = 0 def stpirq(which): global Markers # count of stop sensors global ssense # sensor "value" for main prog if (stp.value() == 1): # Black led2.off() # side LED ssense = 0 else: # white led2.on() # side LED ssense = 100 Markers+=1 print (which) # set up interrupt handler for pin stp as stpirq() stp.irq(handler=stpirq,trigger=Pin.IRQ_FALLING|Pin.IRQ_RISING) while True: time.sleep(1) print (Markers,ssense)