#include <avr/sleep.h>
int ledPin = 13;
int ledDelay = 1000; // Blink every 1 second
int currentDelay = 1000; // Measure current every 1 seconds
float currentConversion = 5.0 / 1023.0 /0.1; // Convert ADC value to mA
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT); // Set pin 13 as output
}
void loop() {
// Blink LED
digitalWrite(ledPin, HIGH);
delay(ledDelay);
digitalWrite(ledPin, LOW);
delay(ledDelay);
// Measure current
float current = analogRead(A0) * currentConversion;
Serial.println(current);
// Put Arduino into sleep mode for currentDelay
set_sleep_mode(SLEEP_MODE_IDLE);
sleep_enable();
delay(currentDelay);
sleep_disable();
}