You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the attachInterrupt() function set Pullups/Pulldowns are reset, the Pin is left floating.
When setting the pinMode after attaching the interrupt, it does work fine. However this is inconsistent with most examples which set the pinMode before attaching the Interrupt (e.g. https://www.arduino.cc/reference/en/language/functions/external-interrupts/attachinterrupt/; also on the Arduino Giga Cheat Sheet)
It is also inconsistent with Arduino Mega, where the pinMode does not get reset after the attachInterrupt() call.
Example Code:
volatileint count = 0;
const byte pin = 2;
voidsetup() {
Serial.begin(9600);
//pinMode(pin, INPUT_PULLDOWN); // Setting the Pin Mode here does not work!attachInterrupt(digitalPinToInterrupt(pin), ISR_count, RISING);
pinMode(pin, INPUT_PULLDOWN); // Pin Mode has to be set after the attachInterrupt()delay(100);
Serial.println("Start");
}
voidloop() {
Serial.println(String("Pin State: ") + digitalRead(pin) + String(" Interrupt Count: ") + count);
}
voidISR_count() {
count++;
}
The text was updated successfully, but these errors were encountered:
Hit the same issue, as above moving pinmode after attachinterrupt fixes this pullup issue, but means the activation of the pull-up (or down) can cause an interrupt.
When using the attachInterrupt() function set Pullups/Pulldowns are reset, the Pin is left floating.
When setting the pinMode after attaching the interrupt, it does work fine. However this is inconsistent with most examples which set the pinMode before attaching the Interrupt (e.g. https://www.arduino.cc/reference/en/language/functions/external-interrupts/attachinterrupt/; also on the Arduino Giga Cheat Sheet)
It is also inconsistent with Arduino Mega, where the pinMode does not get reset after the attachInterrupt() call.
Example Code:
The text was updated successfully, but these errors were encountered: