Some time in the past the behaviour of
analogRead() must have changed to only store the pevious pin mode and leaving the recalling of that state to an eventual call of
This seems to be impacting your case, but you still have not told us which mode you need for your interrupts - despite being asked at least twice.
INPUT_PULLDOWN or even
It depends how long you’d be planning to make your
For a single read, that should be good, but if you intended to do some averaging or other treatment that may take more than just a microseconds (up to a few milliseconds). If it may take any longer I’d
attachInterrupt() again when done.
I’d think the sweet spot between the two would be about 5-10 times the overhead of the latter approach should be where you may want to consider transitioning.
You could also do some tests yourself what works best and maybe gives you the best performance.
e.g. what is faster reverting to the original pin mode: explicitly calling
pinMode() or letting a dummy
digitalRead() do it implicitly or if you’d have a
digitalRead() in your normal logic, just let it do the job then.