Skip to content

Commit 703ff60

Browse files
committed
Revamp standby example
1 parent d035116 commit 703ff60

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

examples/DeepSleep_WakeFromRTC_H7/DeepSleep_WakeFromRTC_H7.ino

+27-8
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,39 @@
1-
#include "Arduino.h"
21
#include "Arduino_PowerManagement.h"
32

43
Board board;
54

6-
75
void setup() {
86
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+
922
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+
}
1231
}
13-
board.enableWakeupFromRTC();
14-
board.sleepFor(0, 0, 1);
1532

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
1837
board.setAllPeripheralsPower(false);
1938
board.standByUntilWakeupEvent();
2039
}

0 commit comments

Comments
 (0)