File tree 1 file changed +27
-8
lines changed
examples/DeepSleep_WakeFromRTC_H7
1 file changed +27
-8
lines changed Original file line number Diff line number Diff line change 1
- #include " Arduino.h"
2
1
#include " Arduino_PowerManagement.h"
3
2
4
3
Board board;
5
4
6
-
7
5
void setup () {
8
6
board = Board ();
7
+
8
+ // When uploading this sketch to the M4 core, it just goes to standby mode.
9
+ #if defined(ARDUINO_GENERIC_STM32H747_M4)
10
+ board.standByUntilWakeupEvent ();
11
+ return ;
12
+ #endif
13
+
14
+ // Turn off the built-in LED
15
+ pinMode (LED_BUILTIN, OUTPUT);
16
+ digitalWrite (LED_BUILTIN, HIGH);
17
+
18
+ // Turn on the blue LED to show that the board is still awake
19
+ pinMode (LEDB, OUTPUT);
20
+ digitalWrite (LEDB, LOW);
21
+
9
22
if (!board.begin ()){
10
- Serial.println (" Board initialization failed." );
11
- while (true );
23
+ // If the board fails to initialize, it will blink the red LED
24
+ pinMode (LEDR, OUTPUT);
25
+ while (true ){
26
+ digitalWrite (LEDR, LOW);
27
+ delay (1000 );
28
+ digitalWrite (LEDR, HIGH);
29
+ delay (1000 );
30
+ }
12
31
}
13
- board.enableWakeupFromRTC ();
14
- board.sleepFor (0 , 0 , 1 );
15
32
16
- pinMode (LEDB, OUTPUT);
17
- digitalWrite (LEDB, LOW);
33
+
34
+ board.enableWakeupFromRTC (0 , 0 , 10 ); // Sleep for 10 seconds
35
+
36
+ // The LED should go off when the board goes to sleep
18
37
board.setAllPeripheralsPower (false );
19
38
board.standByUntilWakeupEvent ();
20
39
}
You can’t perform that action at this time.
0 commit comments