Interrupt: how to detect polarity?
Posted: Sun Dec 22, 2019 10:01 pm
How can I detect both that an interrupt has happened and if it was rising or falling? Having two interrupts on the same pin, like in the code below, did not work.
Code: Select all
void setup() {
WiFi.forceSleepWake();
delay(100);
Serial.begin(1000000); pinMode( LED, OUTPUT );
pinMode( interruptPin, INPUT );
//attachInterrupt(digitalPinToInterrupt(interruptPin), handleInterrupt, CHANGE);
attachInterrupt(digitalPinToInterrupt(interruptPin), handleInterruptR, RISING);
attachInterrupt(digitalPinToInterrupt(interruptPin), handleInterruptF, FALLING);
Serial.println("\nStart");
}
ICACHE_RAM_ATTR void handleInterruptR() {
digitalWrite( LED, HIGH );
}
ICACHE_RAM_ATTR void handleInterruptF() {
digitalWrite( LED, LOW );
}