-
-
Notifications
You must be signed in to change notification settings - Fork 34
Sleep Mode for AVR
Michael Miller edited this page Mar 24, 2016
·
1 revision
If you want to have your project deep sleep and use less power, you can call the EnterSleep()
method and pass in one of the sleep modes as defined in Arduino AVR header sleep.h. The default is SLEEP_MODE_PWR_DOWN
if you don't provide one.
The processor will be placed into the given sleep mode until it is awaken. Different sleep modes have different actions that can cause it to wake. But external interrupts will wake up the Arduino for all sleep modes. Often the idle sleep modes will wake up every 1ms due to the millis()
is implemented using a hardware timer interrupt that will cause the CPU to wake up.
Serial.println("sleep");
// flush is important, we are about to sleep the complete Arduino and
// you would not see the println above without it
Serial.flush();
taskManager.EnterSleep(); // this will not return until something wakes the Arduino
Serial.println("AWAKE");
Serial.flush();
As this example demonstrates, once the Arduino wakes up, it continues running right after the call to EnterSleep()