im suffering with a little problem here with external interrupts. Im using some bottons to trigger external interrupts. okay there might be problems like bouncing etc but in my case this should be the problem.
So as you can see i use in this case 4 different buttons to stop a forloop. This kind of code works well. But bevor this, i use Falling edge instead of the LOW level in the external interrupt. There the problem appears that when i want to use the funktion drive() again it acts like there are interrupts at all pins. After that, if i call it again it acts normal.
My solution was to switch to "LOW" in the attach interrupt. So it seem to me that it doesnt correctly clear the interrupt when im using "Falling edge"
Is there a possibel explanation for this behavior?
Why not just leave them all attached and react to the button presses with an ISR for each ? It involves no more wiring and uses the same number of pins, but the program would be a lot less complicated.
Come to that, do you actually need interrupts at all ? What is the purpose of your program ?
That might be an option. But later i want to turn them off anyway. But that discuission wasnt my real question. My code is working. But i didnt get it why it does with the "LOW" Level Int, but not with the "Falling" edge.
The solution to get the "FALLING" Int working is to remove the detachinterrupt() out of the ISR. Maybe it cancled bevor something comparing in the chip could be resetted to compare a "new falling edge".
Interrupts are automatically disabled whilst in an ISR, so who knows what the effect of detaching them from within an ISR is. If you need to detach interrupts "later" then do it when you need to, not every time the ISR is called.
As you have not posted all of your program or any inkling of what it does as a whole it is still not obvious that you need to use interrupts at all.