4

An ISR should be kept as short as possible, since while it runs, no other interrupts can be handled (including the one powering the delay() function. Thus you cannot delay that easy inside an ISR and you shouldn't do it either. Instead you should set a simple flag variable in the ISR and then check this flag inside your loop() function. If the flag is set, ...


2

In your code you are using the measurement_finished variable as a flag, that a new measurement was finished inside the ISRs, so that it can be handled inside the loop() function. This is very useful. As I understood, an open circuit means, that no measurement can happen, since no pulses are created. So you need to check, how much time passed since the last ...


1

I cannot see what actually goes wrong, but you're calling way too much stuff in your ISR. You're changing non-volatile variables with the control() call in your ISR, leading to undefined behaviour: You don't know when the ISR is being called, especially not whether it is called before or after the non-volatile variables have been transferred from memory to ...


1

Your explanation of what you expect to happen is not very clear but I'll take a stab at your question. First thing - Interrupt Service Routines (ISR) need to be short (execution time, not necessarily code length). Do the minimum necessary to save whatever status or data caused the interrupt and exit. Let the background (your main sketch) handle any further ...


1

I tried to understand your program and found quite a few issues, which I am listing below. This is more a general review than a specific answer. I hope it nevertheless helps you fix the code. The major issue is the logic of loop() being quite convoluted and hard to follow. My guess is that the issue you face is a direct consequence of this single problem. I ...


Only top voted, non community-wiki answers of a minimum length are eligible