Problem with sleep mode: interrupt working only with LOW mode [solved]

Hi
I’m trying to learn how to use interrupts and sleep mode for some project I’m doing so I wrote this program (I’m working with Arduino Mega 2560):

#include <avr/sleep.h>

#define PIN 3

void setup() {
  Serial.begin(9600);
  pinMode(PIN, INPUT_PULLUP);
  Serial.println("Starting");
  
}

void loop() {
  
  delay(3000);
  Serial.println("Zzz...");
  delay(10);
  sleep_enable();
  attachInterrupt(digitalPinToInterrupt(PIN), wakeup, LOW);
  set_sleep_mode(SLEEP_MODE_PWR_DOWN);
  sleep_cpu();
  sleep_disable();
  detachInterrupt(digitalPinToInterrupt(PIN));
  Serial.println("Good morning");
}

void wakeup(){}   //empty function just for waking up the controller

This code works fine - it’s printing ‘Zzz…’ and than goes to sleep until PIN3 is LOW.

The problem start when I’m changing the line:
attachInterrupt(digitalPinToInterrupt(PIN), wakeup, LOW);
to any mode other than LOW (CHANGE \ HIGH \ …) - In this case it’s going to sleep but I can’t wake it up.
Does anybody konw why this is happening?

There is a footnote in the table of sleep modes: "3. For INT7:4, only level interrupt.". Pin 3 is INT5 so while in any sleep mode deeper than "IDLE" it only wakes the processor when set to interrupt on a level (LOW) and not on an edge (RISING, FALLING, or CHANGE).

This implies that edge detection works on INT0, INT1, INT2 and INT3: Pins 21, 20, 19, and 18

johnwasser:
There is a footnote in the table of sleep modes: “3. For INT7:4, only level interrupt.”. Pin 3 is INT5 so while in any sleep mode deeper than “IDLE” it only wakes the processor when set to interrupt on a level (LOW) and not on an edge (RISING, FALLING, or CHANGE).

This implies that edge detection works on INT0, INT1, INT2 and INT3: Pins 21, 20, 19, and 18

Thanks, I’ve changed the pin to 20 and now it’s working :slight_smile: