onPinFall and onPinRise not doing what they should?


I have been trying to get the interrupt functions to work, but I’m getting strange results. If I use onPinFall it appears to not work at all. If I use onPinRise the function is called when the pin goes high AND when the pin goes low.  I tried the interrupt example, direct cut and paste, using onPinFall and it didn’t work either. 
I’m using Linux Mint 18.3, Zerynth 2.1, and an Arduino Due.
I’ve attached my full program, and a copy of the output. You can see that the “released” function gets called but the “pressed” function is never called. You can also see a few places where  “release” is called when I have pressed the button, and is then called again when I release the button. It is also called twice when I have quickly pressed and released the button.
What am I doing wrong?
:frowning: Ian


Hi mogplus8,

this is a known issue, and we are already working on it.
SAM3X devices (ArduinoDue and Flip&Click) have a bug in their onPinFall function.
Try to build your application, at least for now, with the onPinRise waiting for our updates.

Stay tuned :) 


Ok, thanks Matteo. No rush, just thought I was doing something wrong.
:wink: Ian


Hi mogplus8,

onPinFall and onPinRise function are now fixed for sam3x based devices (arduino due and flipnclick).
To test it, you have to create a new virtual machine for your device (don’t worry the number of your available licenses will not decrement) and virtualize it again.

Let me know if this fixes your problem :slight_smile:


I can confirm that the problem is now fixed for Arduino DUE


Thanks Matteo. I have been away for the last few weeks and haven’t had a chance to test this again. I will have another go at it in the next few days hopefully. Thanks to nborrell for confirming.
While I have your attention I have another query about interrupts. I have 18 pins of my Due connected to switches, and I’d like to have an interrupt on each one. Is it possible to put an interrupt in a loop? i.e.

for swPin in range (22, 39)
      onPinFall (swPin, doSwitchCheck)
      onPinRise (swPin, doSwitchCheck)

Then the function doSwitchCheck has a bunch of if / elif / else statements in it to determine which pin activated the interrupt. Or do I have to code each interrupt separately?

Thanks, Ian


Hi Ian,

it is definitely possible to set your callbacks in a loop and to have the same function for all of your pins.
Anyway I suggest you to pass the pin as an argument to your callback:

for swPin in range (22, 39)
      onPinFall (swPin, doSwitchCheck, swPin)
      onPinRise (swPin, doSwitchCheck, swPin)

to ease the process of determining which pin activated the interrupt.
Let me know if everything works as expected :slight_smile:


Particle Photon here, both pinrise and pinfall do not work at all.

Verified the pins are reading low and high correctly with digitalRead, it just doesn’t kick off the callback functions

onPinRise(pir_pin, motion_on)
onPinFall(pir_pin, motion_off)