Hello Arduino friends,
I got a question for the Arduino Nano every. I tried to put the Arduino to sleep but when i loaded up the sketch and tried to power it externally and measure the power input it said 25mA on 5V input. This is not Low Power xD. So I used this following sketch:
#include <avr/sleep.h>
#define INT_PIN 2
#define LED_PIN 9
void setup()
{
Serial.begin(9600);
Serial.println("Start ...");
pinMode(INT_PIN, INPUT);
pinMode(LED_PIN, OUTPUT);
Serial.println("Init done");
}
void loop()
{
Serial.println("Blink");
digitalWrite(LED_PIN, HIGH);
delay(2000);
digitalWrite(LED_PIN, LOW);
delay(2000);
enter_sleep();
Serial.println("woke up ...");
delay(100);
}
void enter_sleep()
{
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_enable();
Serial.println("going to sleep ...");
delay(50);
sleep_cpu();
attachInterrupt(digitalPinToInterrupt(INT_PIN), INT_PINisr, RISING);
}
void INT_PINisr()
{
Serial.println("Interrupt");
sleep_disable();
}
I also tried to get an Interrupt on pin 2 which is a piezo-element. if any one could help me get the arduino to sleep i would be very happy.
Thanks.