I'm trying to understand interrupts in the UNO board.
I've read the attachInterrupts function docs . For this board there are two interrupts: INT0 in pin #2 and INT1 in pin #3.
The third parameter to this function is the MODE, which according to the docs can take four different values in this board:
- LOW: trigger the interrupt whenever the pin is low
- CHANGE: trigger the interrupt whenever the pin changes value
- RISING: trigger when the pin goes from low to high
- FALLING: for when the pin goes from high to low
Well, I've tested all four modes and what I'm getting instead is this:
- LOW: ISR fired once when pin changes from low to high
- CHANGE: ISR fired continuously while pin is low, no action when pin is high
- RISING: works as expected
- FALLING: Same as CHANGE.
Here's my code. I've attached a switch to the interrupt pin #2 (or #3 when testing INT1), and a buzzer to the pin #7 (the ISR plays a tone for 1 second).
static const int INTERRUPT_NUMBER = 0;
static const int INTERRUPT_MODE = RISING;
void setup() {
attachInterrupt(INTERRUPT_NUMBER, beep, INTERRUPT_MODE);
}
void loop() {
}
void beep(){
tone(7, 440, 1000);
}
Is this normal? Could my board be faulty?
