Hi! I'm trying to learn how to use the sleep mode on SAMD board (Nano IoT). The problem I have is that I can't find enough example sketches on Google that work with the IoT and the only documentation I depend on is the one from Arduino page, which is not very thorough.
Anyway, here is my current sketch:
#include <ArduinoLowPower.h>
void setup() {
pinMode(3, INPUT_PULLUP); //Pin 3.
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
LowPower.attachInterruptWakeup(3, loop, CHANGE);
}void loop() {
digitalWrite(LED_BUILTIN, HIGH);
delay (10000);goSleep();
}void goSleep() {
digitalWrite(LED_BUILTIN, LOW);
LowPower.sleep();
}
At the moment, how it's working is the Arduino goes to sleep after second. When I ground the Pin 3, the LED turns on and quickly turns off right away -- but the Arduino stays on sleep mode.
Also with this, as I understand:
LowPower.attachInterruptWakeup(3, loop, CHANGE);
The "CHANGE" means like a change in the value of the pin? Is CHANGE used for sensors like LDR?
And for the "loop" part, is there a way I can resume the Arduino doing it's last job before going to sleep instead of resetting it to loop()?
Also can you please show me a very basic example of the low power sketch without calling a function -- just waking up the Arduino and resuming its last state / job before sleeping? I think how I wrote this basic sketch is wrong since it's not even waking up from sleep.