Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: Searching for simple sleep-Example for Teensy 3.2

  1. #1
    Junior Member
    Join Date
    May 2022
    Posts
    2

    Searching for simple sleep-Example for Teensy 3.2

    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

  2. #2
    Junior Member
    Join Date
    May 2022
    Posts
    2
    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);
      }
    }

  3. #3
    Senior Member BriComp's Avatar
    Join Date
    Apr 2014
    Location
    Cheltenham, UK
    Posts
    754
    You have not said what your problem is.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •