#include <Arduino.h>
#include <avr/sleep.h>
uint8_t wakePin = 2;
uint8_t led=13;
void go_to_sleep();
void wakeUp_isr();
void wakeUp_isr() {
// Code to exectue on wake up.
}
void setup() {
pinMode(wakePin, INPUT_PULLUP);
pinMode(led, OUTPUT);
attachInterrupt(0, wakeUp_isr, LOW);
}
void go_to_sleep() {
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_enable();
attachInterrupt(0,wakeUp_isr, LOW);
sleep_mode();
sleep_disable();
detachInterrupt(0);
}
void loop() {
digitalWrite(led, HIGH);
delay(1000);
digitalWrite(led, LOW);
go_to_sleep();
}