PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 line
751B

  1. // **** INCLUDES *****
  2. #include "LowPower.h"
  3. // Use pin 2 as wake up pin
  4. const int wakeUpPin = 2;
  5. void wakeUp()
  6. {
  7. // Just a handler for the pin interrupt.
  8. }
  9. void setup()
  10. {
  11. // Configure wake up pin as input.
  12. // This will consumes few uA of current.
  13. pinMode(wakeUpPin, INPUT);
  14. }
  15. void loop()
  16. {
  17. // Allow wake up pin to trigger interrupt on low.
  18. attachInterrupt(0, wakeUp, LOW);
  19. // Enter power down state with ADC and BOD module disabled.
  20. // Wake up when wake up pin is low.
  21. LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);
  22. // Disable external pin interrupt on wake up pin.
  23. detachInterrupt(0);
  24. // Do something here
  25. // Example: Read sensor, data logging, data transmission.
  26. }