]> git.piffa.net Git - arduino/blob - books/ArduinoNextSteps-master/ArduinoNextSteps/wake_sleep_example/wake_sleep_example.ino
first commit
[arduino] / books / ArduinoNextSteps-master / ArduinoNextSteps / wake_sleep_example / wake_sleep_example.ino
1 // sketch_03_03_1kHz
2 #include <avr/sleep.h>
3 #include <avr/power.h>
4 #include <TimerOne.h>
5
6 NO NARCOLEPTIC LIBARAY IS THE WAY TO GO FOR THIS - THEN DELVE INTO HOW NARCOLEPTIC WORKS.
7
8 ALSO THE POWER LIBRARY.
9
10 int ledPin = 13;
11
12 void setup() 
13 {
14   pinMode(ledPin, OUTPUT);
15   Timer1.initialize(5000000); // wake every 5 seconds 
16   //Timer1.attachInterrupt(everySoOften); 
17   TIMSK1=0x01;
18 }
19  
20 void loop()
21 {
22   digitalWrite(ledPin, HIGH);
23   delayMicroseconds(250000);
24   digitalWrite(ledPin, LOW);
25   delayMicroseconds(250000);
26   
27   set_sleep_mode(SLEEP_MODE_IDLE);
28   sleep_enable();
29   power_adc_disable();
30   power_spi_disable();
31   power_timer0_disable();
32   power_timer2_disable();
33   power_twi_disable();  
34   sleep_mode();
35 }
36
37 //void everySoOften()
38 //{
39 //  
40 //}
41
42 // http://donalmorrissey.blogspot.co.uk/2011/11/sleeping-arduino-part-4-wake-up-via.html