Searching for simple sleep-Example for Teensy 3.2

RaphoZ

New member
Hello,

iam using a Teensy 3.2 in Arduino-language and i want to use the sleep-mode. Iam pretty confused about the big amount of sleepmode-types and variants to start and stop the sleepmodes.

I rode some other posts in this forum in which the the sleepmode in combination with timers are discussed.

I just want to sent the teensy into sleepmode and wake it up using two interupt pins. It would be nice if the current would be less than 1 mA when it sleeps.

Can someone give me a minimal code for this funktion?

I think its necessary to use the snooze.h libary ...

Best regards
Raphael
 
Hello, I have been able to answer my question myself. There is a sample code of "snooze.h", but I had not understood it. If someone has the same problem as me, here is a short explanation and a small sample code.

Code:
#include <Snooze.h>

SnoozeDigital digital;

SnoozeBlock config(digital);
void setup() {
pinMode(LED_BUILTIN, OUTPUT);

digital.pinMode(21, INPUT_PULLUP, RISING);//Pin 21 is used as interupt pin to wake up the teensy from sleeping
}

void loop() {

  int who = Snooze.deepSleep( config );// this codeline puts the teensy into sleep-mode now
                                                     // Teensy sleeps until it get waked up with Pin21
                                                     // When it get waked up, this function gives back the number of "waking-up-reason" to "who"

  for(int i=0; i<who; i=i+1) //blinks 21 times if controller was waked up by Pin 21
  {
    digitalWrite(LED_BUILTIN, HIGH);
    delay(200);
    digitalWrite(LED_BUILTIN, LOW);
    delay(200);
  }
}
 
Back
Top