[closed] Interrupt and digital input on same pin

Hi all,

I would like to know if it's possible to attach an interrupt to digital pin 2 (which is used to wake up an Arduino Uno when it's in sleep mode) and also use this digital pin as an input to detect a button press, if the arduino is not in sleep mode?

Thanks in advance.

Best regards,


Yes. Activate the interrupt before sleep and turn it off when you wake up.

Yes; you can always read the pin even if it’s also set as an interrupt. (though if you only wanted the interrupt for wakeup purposes, you’d have to disable or handle it “silently” when the processor is awake.) (You can output to an interrupt pin as well; it’s even a recommended technique for implementing a “software interrupt.”)