Hi, I am doing tests with an ESP8266-12F and I want to implement an external interrupt through the GPIO14, when pressing the button you can see that there is noise and I have tried to add a debounce with a delay in the interrupt routine, it has improved but I still have some jumps Can someone tell me what is the best method to implement a debounce with an external interrupt?
Here is my code:
int interruptPin(14);
int numberOfInterrupts = 0;
void setup() {
Serial.begin(115200);
Serial.println();
Serial.println("Interrupt Test");
pinMode(interruptPin, INPUT);
attachInterrupt(digitalPinToInterrupt(interruptPin), IntCallback, FALLING);
}
void loop() {
}
void IntCallback() {
detachInterrupt(digitalPinToInterrupt(interruptPin));
if (!digitalRead(interruptPin)) {
delay(1000);
if (!digitalRead(interruptPin)) {
numberOfInterrupts = numberOfInterrupts + 1;
Serial.print("Interrupcion Nro = ");
Serial.println(numberOfInterrupts);
}
}
attachInterrupt(digitalPinToInterrupt(interruptPin), IntCallback, FALLING);
}
My thought is to disable interrupt even after leaving the interrupt routine. Then disabling enabling it after some millis(). Kind of a odd debounce function.