This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision | |||
|
lab6 [2018/11/08 22:12] dan.tudose |
lab6 [2018/11/08 22:13] (current) dan.tudose |
||
|---|---|---|---|
| Line 11: | Line 11: | ||
| <code C> | <code C> | ||
| - | #include < | + | /* This is an example for SparrowVSleep library. |
| + | You need to call SparrowV_SleepInit function. | ||
| + | The funciton has 2 params. | ||
| + | 1st param: integer (> 1 second, greater than 1 second) (represent time in seconds, how long the board will sleep) | ||
| + | 2nd param: bool (true - with data retention, false - with no data retention) | ||
| + | In case of no data retention the board can sleep max 8 secons and it will | ||
| + | reboot after time end. | ||
| + | */ | ||
| - | int led = 11; | + | #include < |
| - | int state = 0; | + | |
| - | + | ||
| - | void setup() { | + | |
| - | + | ||
| - | pinMode(led, | + | |
| + | void setup() { | ||
| Serial.begin(9600); | Serial.begin(9600); | ||
| - | Serial.println(" | ||
| - | | ||
| - | ZigduinoSleepInit(); | ||
| } | } | ||
| void loop() { | void loop() { | ||
| - | | + | // put your main code here, to run repeatedly: |
| - | + | | |
| - | //Code that is executed before sleep | + | |
| - | state ^= 1; | + | Serial.flush(); |
| - | if(state == 0) digitalWrite(led, HIGH); | + | |
| - | else digitalWrite(led, LOW); | + | //sleep for 25 seconds with data retention |
| - | | + | SparrowV_SleepInit(25, true); |
| - | | + | |
| - | | + | Serial.println(" |
| - | | + | Serial. println(" |
| - | | + | Serial. |
| - | + | Serial.flush(); | |
| - | //End of code | + | delay(5000); |
| - | + | ||
| - | | + | |
| - | + | ||
| } | } | ||
| </ | </ | ||