More than one attachInterrupt on the same pin

I am on Photon 0.7.0-rc.4
I am refining a program that has 4 touch capacitive buttons 1 to 4 each attached to D4, D5, D6 and D7 respectively.

I use button1 to allow detection of a wake by user event from sleep on touching the button1. System.sleep(button1, RISING, SLEEPTIME);

All the pins are setup thus: pinMode(button1, INPUT_PULLDOWN);

I am also using the same pin to re-light a dimmed screen attached to an ISR thus: attachInterrupt(button1, wakeupButtonPressed, FALLING); The ISR routine simply sets a volatile bool which is detected and reset in the application.

This was all working fine. I then tried to add an ISR thus to each button; attachInterrupt(button1, button1Pressed, RISING);

The idea being to note the time using millis() that the button was pressed (volatile uint32_t used) so that in the application I could tell whether the button had been pressed and held for a certain period. This does not appear to be working - can I assume that attachInterrupt can only be used once per pin even if the ISR and mode are different?

Exactly.
If you want to detect the rising and the falling edge, you need to go for a CHANGE interrupt and read the state of the pin as fast as possible after the trigger (e.g. pinReadFast())

2 Likes