Skip to content

Commit 20cc1ba

Browse files
committed
Simplify example
1 parent 7c526e9 commit 20cc1ba

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

examples/WakeFromPin/WakeFromPin.ino

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
* - Select the Portenta C33 board from the Tools menu
1919
* - Select the Portenta C33's USB port from the Tools menu
2020
* - 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
2323
* (If you need information about how to wire the buttons check this link: https://docs.arduino.cc/built-in-examples/digital/Button/)
2424
*
2525
* Initial author: C. Dragomir
@@ -56,25 +56,26 @@ LowPower lowPower;
5656
#endif
5757

5858
void goToSleep(){
59+
// Turn off the built-in LED before going to sleep
60+
digitalWrite(LED_BUILTIN, HIGH);
61+
5962
#ifdef TURN_PERIPHERALS_OFF
6063
turnPeripheralsOff();
61-
#else
62-
// Turn off the built-in LED before going to sleep
63-
digitalWrite(LED_BUILTIN, HIGH);
6464
#endif
6565
lowPower.deepSleep();
6666
}
6767

6868
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);
7272

7373
// Register the callback function to put the device to sleep when the button is pressed
7474
attachInterrupt(digitalPinToInterrupt(SLEEP_PIN), goToSleep, FALLING);
7575
lowPower.enableWakeupFromPin(WAKE_PIN, FALLING);
7676

7777
pinMode(LED_BUILTIN, OUTPUT);
78+
digitalWrite(LED_BUILTIN, LOW); // Turn the built-in LED on to indicate the device is awake
7879

7980
#ifdef TURN_PERIPHERALS_OFF
8081
PMIC.begin();

0 commit comments

Comments
 (0)