diff --git a/lowpower.ino b/lowpower.ino new file mode 100644 index 0000000..ccd03e3 --- /dev/null +++ b/lowpower.ino @@ -0,0 +1,50 @@ +#include "LowPower.h" + +int ledPin = 15; +int sleepcycles = 12; // every sleepcycle will last 8 secs, total sleeptime will be sleepcycles * 8 sec +bool joined = false; +bool sleeping = false; + +void setup() +{ + // No setup is required for this library + pinMode(ledPin, OUTPUT); +} + +void loop() +{ + // Enter idle state for 8 s with the rest of peripherals turned off + // Each microcontroller comes with different number of peripherals + // Comment off line of code where necessary + + // ATmega328P, ATmega168 + LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF); + + // ATmega32U4 + //LowPower.idle(SLEEP_8S, ADC_OFF, TIMER4_OFF, TIMER3_OFF, TIMER1_OFF, + // TIMER0_OFF, SPI_OFF, USART1_OFF, TWI_OFF, USB_OFF); + + // ATmega2560 + //LowPower.idle(SLEEP_8S, ADC_OFF, TIMER5_OFF, TIMER4_OFF, TIMER3_OFF, + // TIMER2_OFF, TIMER1_OFF, TIMER0_OFF, SPI_OFF, USART3_OFF, + // USART2_OFF, USART1_OFF, USART0_OFF, TWI_OFF); + + // ATmega256RFR2 + //LowPower.idle(SLEEP_8S, ADC_OFF, TIMER5_OFF, TIMER4_OFF, TIMER3_OFF, + // TIMER2_OFF, TIMER1_OFF, TIMER0_OFF, SPI_OFF, + // USART1_OFF, USART0_OFF, TWI_OFF); + + // Do something here + // Example: Read sensor, data logging, data transmission. + digitalWrite(ledPin, HIGH); + delay(5000); + digitalWrite(ledPin, LOW); + delay(1000); + + sleeping = false; + for (int i=0;i