Skip to main content

Interrupts

Hardware interrupts can invoke a function using IStart(func, pin, trigger, pull) on pin change; where trigger is: 0- Falling edge, 1- Rising edge, and 2- Falling & Rising edges. Pull is: 0- none, 1- up, 2- down.

tip

This only works on interrupt-capable pins.

The func function must not take any argument.

_b = 0
# Call "Blink()" when pin 2 goes low. Enable the pull-up resistor.
IStart("Blink", 2, 0, 1)

while 1
PrintLn("Stat: ", Istat("Blink"))
Wait(1000)
wend

fn Blink()
DWrite(0, _b&1)# Status LED is always on pin 0
_b=_b+1
PrintLn("Blink: ", _b)
if _b=10# stop the interrupt after 100 interrupts
IAbort("Blink")
end
fend