|
18 | 18 | * - Select the Portenta C33 board from the Tools menu
|
19 | 19 | * - Select the Portenta C33's USB port from the Tools menu
|
20 | 20 | * - Upload the code to your Portenta C33
|
21 |
| -* - Connect a button to pin D0 and ground (internal pull-up resistor is enabled) |
22 |
| -* - Connect a button to pin A3 and ground (internal pull-up resistor is enabled) |
| 21 | +* - Connect a button to pin D0 and ground with a pull-up resistor to 3.3V |
| 22 | +* - Connect a button to pin A3 and ground with a pull-up resistor to 3.3V |
23 | 23 | * (If you need information about how to wire the buttons check this link: https://docs.arduino.cc/built-in-examples/digital/Button/)
|
24 | 24 | *
|
25 | 25 | * Initial author: C. Dragomir
|
@@ -56,25 +56,26 @@ LowPower lowPower;
|
56 | 56 | #endif
|
57 | 57 |
|
58 | 58 | void goToSleep(){
|
| 59 | + // Turn off the built-in LED before going to sleep |
| 60 | + digitalWrite(LED_BUILTIN, HIGH); |
| 61 | + |
59 | 62 | #ifdef TURN_PERIPHERALS_OFF
|
60 | 63 | turnPeripheralsOff();
|
61 |
| - #else |
62 |
| - // Turn off the built-in LED before going to sleep |
63 |
| - digitalWrite(LED_BUILTIN, HIGH); |
64 | 64 | #endif
|
65 | 65 | lowPower.deepSleep();
|
66 | 66 | }
|
67 | 67 |
|
68 | 68 | void setup(){
|
69 |
| - // Register the sleep and wake-up pins as inputs with pull-up resistors |
70 |
| - pinMode(SLEEP_PIN, INPUT_PULLUP); |
71 |
| - pinMode(WAKE_PIN, INPUT_PULLUP); |
| 69 | + // External pull-up resistor used for the buttons |
| 70 | + pinMode(SLEEP_PIN, INPUT); |
| 71 | + pinMode(WAKE_PIN, INPUT); |
72 | 72 |
|
73 | 73 | // Register the callback function to put the device to sleep when the button is pressed
|
74 | 74 | attachInterrupt(digitalPinToInterrupt(SLEEP_PIN), goToSleep, FALLING);
|
75 | 75 | lowPower.enableWakeupFromPin(WAKE_PIN, FALLING);
|
76 | 76 |
|
77 | 77 | pinMode(LED_BUILTIN, OUTPUT);
|
| 78 | + digitalWrite(LED_BUILTIN, LOW); // Turn the built-in LED on to indicate the device is awake |
78 | 79 |
|
79 | 80 | #ifdef TURN_PERIPHERALS_OFF
|
80 | 81 | PMIC.begin();
|
|
0 commit comments