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?