|
123456789101112131415161718192021222324252627282930313233 |
- // **** INCLUDES *****
- #include "LowPower.h"
-
- // Use pin 2 as wake up pin
- const int wakeUpPin = 2;
-
- void wakeUp()
- {
- // Just a handler for the pin interrupt.
- }
-
- void setup()
- {
- // Configure wake up pin as input.
- // This will consumes few uA of current.
- pinMode(wakeUpPin, INPUT);
- }
-
- void loop()
- {
- // Allow wake up pin to trigger interrupt on low.
- attachInterrupt(0, wakeUp, LOW);
-
- // Enter power down state with ADC and BOD module disabled.
- // Wake up when wake up pin is low.
- LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);
-
- // Disable external pin interrupt on wake up pin.
- detachInterrupt(0);
-
- // Do something here
- // Example: Read sensor, data logging, data transmission.
- }
|