Skip to content

Commit e58aebb

Browse files
adding what's needed to enable the softdevice and the power off function
1 parent 9a99c9c commit e58aebb

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

libraries/Bluefruit52Lib/examples/Hardware/blink_sleep/blink_sleep.ino

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
22
Blink_sleep
33
Turns on an LED on for one second, then off for one second, until the time to go to sleep runs out.
4+
You can wake up the feather by pressing a key/switch connecting the WAKE_LOW_PIN to GND and the WAKE_HIGH_PIN to 3.3V (VCC)
45
56
Based on the blinky arduino example
67
@@ -10,6 +11,7 @@
1011
by Pierre Constantineau
1112
1213
*/
14+
#include <bluefruit.h>
1315

1416
#define WAKE_LOW_PIN PIN_A0
1517
#define WAKE_HIGH_PIN PIN_A1
@@ -22,11 +24,11 @@ void gotoSleep(unsigned long time)
2224
if ((time>SLEEPING_DELAY))
2325
{
2426
// to reduce power consumption when sleeping, turn off all your LEDs (and other power hungry devices)
25-
digitalwrite(LED_BUILTIN, LOW);
27+
digitalWrite(LED_BUILTIN, LOW);
2628

2729
// setup your wake-up pins.
28-
pinModeSense(WAKE_LOW_PIN, INPUT_PULLUP_SENSE); // this pin (WAKE_LOW_PIN) is pulled up and wakes up the feather when externally connected to ground.
29-
pinModeSense(WAKE_HIGH_PIN, INPUT_PULLDOWN_SENSE); // this pin (WAKE_HIGH_PIN) is pulled down and wakes up the feather when externally connected to 3.3v.
30+
pinMode(WAKE_LOW_PIN, INPUT_PULLUP_SENSE); // this pin (WAKE_LOW_PIN) is pulled up and wakes up the feather when externally connected to ground.
31+
pinMode(WAKE_HIGH_PIN, INPUT_PULLDOWN_SENSE); // this pin (WAKE_HIGH_PIN) is pulled down and wakes up the feather when externally connected to 3.3v.
3032

3133
// power down nrf52.
3234
sd_power_system_off(); // this function puts the whole nRF52 to deep sleep (no Bluetooth). If no sense pins are setup (or other hardware interrupts), the nrf52 will not wake up.
@@ -35,6 +37,8 @@ void gotoSleep(unsigned long time)
3537

3638
// the setup function runs once when you press reset or power the board
3739
void setup() {
40+
Bluefruit.begin(); // Sleep functions need the softdevice to be active.
41+
3842
// initialize digital pin LED_BUILTIN as an output.
3943
pinMode(LED_BUILTIN, OUTPUT);
4044
}

0 commit comments

Comments
 (0)