I've tried unsuccessfully to use ArduinoLowPower and Low-Power libraries to wake up from sleeping using a digital input event.
I have tried every combination. I have search the internet (I found other with same problem with no solution).
This is my typical test sketch.
type or pa /* If no external event on Pin schedule run as expected i.e. LEDs will flash than a delay of 4 seconds and then repeat. If external "wakeup during 4 second sleep, a single 4 second LED flash and then start over.
*/
#include "ArduinoLowPower.h"
#define SerialUSB Serial
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 2;
int count = 0;
int pin = 0;
// the setup routine runs once when you press reset:
void setup() {
SerialUSB.begin(9600);
Serial1.begin(38400);
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
pinMode(pin, INPUT_PULLUP);
LowPower.attachInterruptWakeup(digitalPinToInterrupt(pin), no_BlinkLED, CHANGE); //Wakeup if in LowPower.sleep pin external level change
}
void loop() {
blink_LED();
}
void blink_LED() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
count = count + 1;
if (count < 6) { } // repeat blink sequence 5 times
else {
SerialUSB.println("Go to sleep"); //Go to sleep for 4 seconds
LowPower.sleep(4000);
count = 0;
}
}
//external pin interrupt routine
void no_BlinkLED() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(4000);
count = 0;
}
I have tried a number of other sketches using the Low-Power Libraries and have never been able to use external input to interrupt sleep mode. It appears this may be particular to the SAMD21?
Any help/suggestions much appreciated. Thank you.