Hello everyone ,
I am trying to implement external interrupt using push button in my project But the only problem is when i press the button the interrupt routine is fired several times . i have tried to disable interrupt in interrupt routine using detachInterrupt function but the problem still exist. i have tested the following code in both
arduino uno and
arduino leonardo. So i don`t think that something is wrong with my arduino hardware.
void
setup() {
pinMode (2,INPUT_PULLUP); // turn on pull-up resistors
attachInterrupt(digitalPinToInterrupt(2), INT0_ISR, FALLING);
Serial.begin(9600);
}
void
loop() {
}
void INT0_ISR()
{
Serial.println("interrup fired");
// detachInterrupt(digitalPinToInterrupt(2));
// delay (100);
}
I was watching Jeremy blum`s video on youtube in which he used RC circuit with Schmitt trigger to hardware de-bounce the push button.But i am not sure if it the most efficient way to solve this problem.
Is there any alternative ?
Can I de-bounce this push button in interrupt routine ?
Thanks in advance