2 ms·
Although the author has verified your guess is correct, there is actually a reason one might want to check the pin in the interrupt handler. If the switch boun
by tzs 5y ago
Although the author has verified your guess is correct, there is actually a reason one might want to check the pin in the interrupt handler.
If the switch bounces you can get spurious interrupts. If the maximum bounce period is under the time it takes the Arduino to process the interrupt and call your handler so that you can be sure the pin will be done bouncing by the time your code runs than you can handle this by simply treating the interrupt as an opportunity to poll.
If the switch bounce can be longer than that then you might need software debouncing. Probably the simplest approach there is keep track of the last interrupt time and only treat interrupts as real if they do not occur too soon after the previous interrupt.