Detach interrupt and Analog IN will work as normal Analog IN again?

I use one of the Analog Pins of a Photon for an interrupt from a switch and -because I used all the other inputs on the device as well- I want to use that Analog Input also for measuring some voltage level on that very same input pin.
Is my understanding from the documentation correct that I can switch-off the interrupt-handling-functionality from that pin by using detachinterrupt while doing my analog measurement, and then put the pin in attachinterrupt mode again after I did the analog measurement???

Yup, that should work.

The only thing you need to consider is that you cannot use detachInterrupt() inside the ISR and you need to reapply the pinMode() you need for your interrupt to work.
In previous device OS versions both of these caveats were no issue.
The device OS used to reapply the any previous pin mode if it happened to be set explicitly (not anymore tho’).

Thanks for the quick reaction, ScruffR

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.