Line | |
---|
1 | /********************************************************************************************
|
---|
2 | This sketch demonstrates how sleep function using external interrupt to wake up the MCU.
|
---|
3 | This sketch work only cortex-m0+ boards.
|
---|
4 | *********************************************************************************************/
|
---|
5 |
|
---|
6 |
|
---|
7 |
|
---|
8 | #include <EnergySaving.h>
|
---|
9 |
|
---|
10 | EnergySaving nrgSave;
|
---|
11 |
|
---|
12 | unsigned int i=0;
|
---|
13 |
|
---|
14 | void setup()
|
---|
15 | {
|
---|
16 | nrgSave.begin(WAKE_EXT_INTERRUPT, 8, dummy); //standby setup for external interrupts
|
---|
17 | }
|
---|
18 |
|
---|
19 | void loop()
|
---|
20 | {
|
---|
21 | for(i=0; i<20; i++)
|
---|
22 | {
|
---|
23 | digitalWrite(13,HIGH);
|
---|
24 | delay(500);
|
---|
25 | digitalWrite(13,LOW);
|
---|
26 | delay(500);
|
---|
27 | }
|
---|
28 |
|
---|
29 | nrgSave.standby(); //now mcu goes in standby mode
|
---|
30 | }
|
---|
31 |
|
---|
32 |
|
---|
33 | void dummy(void) //interrupt routine (isn't necessary to execute any tasks in this routine
|
---|
34 | {
|
---|
35 |
|
---|
36 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.