39 lines
894 B
C++
Executable File
39 lines
894 B
C++
Executable File
//Turn off ADC (analog to digital conversion)
|
|
//
|
|
//Next thing we can do turn off the ADC subsystem by adding this line:
|
|
// // disable ADC
|
|
// ADCSRA = 0;
|
|
//
|
|
//With that there the power consumption drops a large amount, down from
|
|
//335 µA to 0.355 µA! (that is, 355 nA)
|
|
|
|
|
|
#include <avr/sleep.h>
|
|
|
|
void setup ()
|
|
{
|
|
|
|
for (byte i = 0; i <= A5; i++)
|
|
{
|
|
pinMode (i, OUTPUT); // changed as per below
|
|
digitalWrite (i, LOW); // ditto
|
|
}
|
|
|
|
// disable ADC
|
|
ADCSRA = 0;
|
|
|
|
set_sleep_mode (SLEEP_MODE_PWR_DOWN);
|
|
noInterrupts (); // timed sequence follows
|
|
sleep_enable();
|
|
|
|
// turn off brown-out enable in software
|
|
MCUCR = bit (BODS) | bit (BODSE);
|
|
MCUCR = bit (BODS);
|
|
interrupts (); // guarantees next instruction executed
|
|
sleep_cpu (); // sleep within 3 clock cycles of above
|
|
|
|
} // end of setup
|
|
|
|
void loop () { }
|
|
|