I think this really simple program should blink a few times and go to sleep forever.
But it blinks 4 times, goes to sleep for about 60 seconds, and then starts blinking forever.
Arduino 1.0 Arduino Pro Mini 328 3.3V powered by FTDI basic 3.3V serial converter from USB
#include <avr/sleep.h>
#include <avr/power.h>
int I;
void enterSleep(void)
{
set_sleep_mode(SLEEP_MODE_IDLE);
sleep_enable();
/* Now enter sleep mode. */
sleep_mode();
/* The program will continue from here after the timer timeout*/
sleep_disable(); /* First thing to do is disable sleep. */
/* Re-enable the peripherals. */
power_all_enable();
}
void setup() {
pinMode(13, OUTPUT);
I = 5;
}
void loop() {
while (I-->1){
digitalWrite(13, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(13, LOW); // set the LED off
delay(1000); // wait for a second
}
enterSleep();
}