That induces a DebounceTime lag after the noise.
Given a noisy signal like (HT Switch - Wikipedia):
What I'm looking for is something that triggers and acts on the leading edge, rather than waiting for a debounceDelay before acting.
Triggering on the leading edge, and then supressing subsequent triggers for a period of time certainly may be susceptible to noise, but on the other hand, a noisy switch can lead to missing signals
For instance, if this pulse was only 5ms long, a debounce scheme that depended on a 3ms debounceDelay would could, because of noise, completely miss the signal. (This reminds me of my frustrating alarm clock, where I really have to grind my thumb into its aged membrane switch)
The code from debouncing an interrupt trigger - #3 by mikalhart triggers quickly and ignores the noise:
void my_interrupt_handler()
{
static unsigned long last_interrupt_time = 0;
unsigned long interrupt_time = millis();
// If interrupts come faster than 200ms, assume it's a bounce and ignore
if (interrupt_time - last_interrupt_time > 200)
{
... do your thing
}
last_interrupt_time = interrupt_time;
}
Do all of the debounce/button libraries follow the lag-inducing pattern of Debounce.ino?
