File tree 1 file changed +13
-7
lines changed
1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change 32
32
#define WAKE_PIN A3 // Pin used to wake up the device
33
33
34
34
LowPower lowPower;
35
+ bool shouldSleep = false ;
35
36
36
37
#ifdef TURN_PERIPHERALS_OFF
37
38
#include " Arduino_PMIC.h"
@@ -56,13 +57,7 @@ LowPower lowPower;
56
57
#endif
57
58
58
59
void goToSleep (){
59
- // Turn off the built-in LED before going to sleep
60
- digitalWrite (LED_BUILTIN, HIGH);
61
-
62
- #ifdef TURN_PERIPHERALS_OFF
63
- turnPeripheralsOff ();
64
- #endif
65
- lowPower.deepSleep ();
60
+ shouldSleep = true ;
66
61
}
67
62
68
63
void setup (){
@@ -83,6 +78,17 @@ void setup(){
83
78
}
84
79
85
80
void loop (){
81
+ if (shouldSleep){
82
+ // Turn off the built-in LED before going to sleep
83
+ digitalWrite (LED_BUILTIN, HIGH);
84
+
85
+ #ifdef TURN_PERIPHERALS_OFF
86
+ turnPeripheralsOff ();
87
+ #endif
88
+ lowPower.deepSleep ();
89
+ shouldSleep = false ;
90
+ }
91
+
86
92
// Blink the built-in LED every 500ms when the device is not sleeping
87
93
digitalWrite (LED_BUILTIN, LOW);
88
94
delay (500 );
You can’t perform that action at this time.
0 commit comments