I've read and re-read the information on Interrupts in the Reference section and am confused about what exactly the Yun allows for external interrupts.
I am trying to detect a button as a LOW on two different inputs using an interrupt. When the first low is detected I will detachinterrupt() and mark the millis() time and perform my task, then in the main Loop I will attachinterrupt after 100 milliseconds has gone by. My version of a debounce routine.
I first tried using digital pins 9 and 10, those don't seem to work as interrupts on the Yun even though the 32U4 indicates they are interrupts.
I then tried digital pins 2 and 3, and those were erratic, one of them caused an interrupt when it shouldn't have. I presume some activity on SCL or SDA caused it, so perhaps these two aren't the best to use.
I then tried digital pins 0 and 1, and I also interrupts I didn't expect due to some spurious activity on those two lines.
In all cases I first set the digital pins to INPUT in the Setup.
What inputs on the Yun can be used for external interrupts?
Note that the attachInterrupt page doesn't list the Yun interrupts. I tried to follow the Leanardo example, but that didn't work.
Dean
Hi,
I have also faced this problem (not with Yun, but with Uno). The interrupt seems to trigger again (which is no need) at the time I re-attached it.
Do you think, usage of timer1 would solve your problem? Meaning, after you receive an interrupt, set a bool flag stating you have received an interrupt (to avoid reprocessing the same block due to false interrupt) and then set a timer of 100 msec or so. After the timer has elapsed, the new block will be executed. In this block you can put your logic and also reset the flag (so that you start processing new interrupts). In this case, you don't need to detach the interrupt.
The only set back with this approach is the processing time available with mcu after you receive the first interrupt. If you keep on getting interrupts, there will be less time available for the loop() block. However you can try various other methods of triggering the interrupt method on FALLING edge rather than LOW.
There may be other better options also to handle this logic. Please feel free to post other ideas / suggestions.
Thanks,
Manoj Rathod.