In the Nightingale example I understand most of it, but can anyone explain the following.
cbi(ADCSRA,ADEN); // switch Analog to Digitalconverter OFF
sbi(ADCSRA,ADEN); // switch Analog to Digitalconverter ON
In the void system_sleep() section , What does this do and why is it needed?
Also, I am a bit confused by the watchdog code.
Where do I set the time I want the watchdog to wait before waking up the Arduino?
void setup_watchdog(int ii) {
byte bb;
int ww;
if (ii > 9 ) ii=9;
bb=ii & 7;
if (ii > 7) bb|= (1<<5);
bb|= (1<<WDCE);
ww=bb;
Serial.println(ww);
MCUSR &= ~(1<<WDRF);
// start timed sequence
WDTCSR |= (1<<WDCE) | (1<<WDE);
// set new watchdog timeout value
WDTCSR = bb;
WDTCSR |= _BV(WDIE);
}