Move master branch from from mios git repo
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
#include <Sleep_n0m1.h>
|
||||
|
||||
Sleep sleep;
|
||||
|
||||
void setup()
|
||||
{
|
||||
|
||||
Serial.begin(9600);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
delay(100); ////delays are just for serial print, without serial they can be removed
|
||||
Serial.println("execute your code here");
|
||||
|
||||
Serial.print("Sleeping Till Interrupt");
|
||||
|
||||
delay(100); //delay to allow serial to fully print before sleep
|
||||
|
||||
sleep.pwrDownMode(); //set sleep mode
|
||||
sleep.sleepInterrupt(0,FALLING); //sleep for: sleepTime
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
#include <Sleep_n0m1.h>
|
||||
|
||||
Sleep sleep;
|
||||
boolean abortSleep; //cancel sleep cycle
|
||||
int sleepCycleCount; //the number of times awake then asleep
|
||||
unsigned long sleepTime; //how long you want the arduino to sleep
|
||||
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
|
||||
Serial.begin(9600);
|
||||
abortSleep = false; //can be used to cancel the sleep cycle
|
||||
sleepTime = 5000; //set sleep time in ms, max sleep time is 49.7 days
|
||||
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
if(abortSleep)
|
||||
{
|
||||
Serial.println("sleep no more!");
|
||||
}
|
||||
else
|
||||
{
|
||||
delay(100);
|
||||
Serial.print("sleeping for ");
|
||||
Serial.println(sleepTime);
|
||||
delay(100); //delay to allow serial to fully print before sleep
|
||||
}
|
||||
|
||||
sleepCycleCount++;
|
||||
if(sleepCycleCount > 5)
|
||||
{
|
||||
abortSleep = true;
|
||||
}
|
||||
|
||||
sleep.pwrDownMode(); //set sleep mode
|
||||
sleep.sleepDelay(sleepTime,abortSleep); //sleep for: sleepTime
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
#include <Sleep_n0m1.h>
|
||||
|
||||
int count = 0;
|
||||
Sleep sleep;
|
||||
unsigned long sleepTime; //how long you want the arduino to sleep
|
||||
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
|
||||
Serial.begin(9600);
|
||||
sleepTime = 50000; //set sleep time in ms, max sleep time is 49.7 days
|
||||
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
delay(100); //delay to allow serial output to be ready after wake up
|
||||
Serial.print("Awake for ");
|
||||
Serial.print(count);
|
||||
Serial.println("sec");
|
||||
|
||||
count++;
|
||||
delay(1000); // waits for a second
|
||||
|
||||
if(count >= 3)
|
||||
{
|
||||
count = 0;
|
||||
Serial.print("sleeping ");
|
||||
Serial.println(sleepTime);
|
||||
delay(100); //delay to allow serial to fully print before sleep
|
||||
|
||||
sleep.pwrDownMode(); //set sleep mode
|
||||
sleep.sleepDelay(sleepTime); //sleep for: sleepTime
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
#include <Sleep_n0m1.h>
|
||||
|
||||
Sleep sleep;
|
||||
unsigned long sleepTime; //how long you want the arduino to sleep
|
||||
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
|
||||
Serial.begin(9600);
|
||||
sleepTime = 50000; //set sleep time in ms, max sleep time is 49.7 days
|
||||
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
delay(100); ////delays are just for serial print, without serial they can be removed
|
||||
Serial.println("execute your code here");
|
||||
|
||||
Serial.print("sleeping for ");
|
||||
Serial.println(sleepTime);
|
||||
delay(100); //delay to allow serial to fully print before sleep
|
||||
|
||||
sleep.pwrDownMode(); //set sleep mode
|
||||
sleep.sleepDelay(sleepTime); //sleep for: sleepTime
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user