Hi,
I try to save power on my leonardo. For that, I use the sleep mode.
Following code is working well:
#include <avr/sleep.h>
void wakeupFunction(){
}
void toSleep(){
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_enable();
attachInterrupt(0,wakeupFunction,LOW); //wakeupbutton : pin 3 on leonardo!!!
sleep_mode();
detachInterrupt(0);
sleep_disable(); //fully awake now
}
void setup()
{
Serial.begin(9600); // Debugging only
pinMode(3, INPUT);
}
void loop()
{
Serial.println("loop()");
digitalWrite(13,HIGH) ;
delay(1000);
digitalWrite(13,LOW) ;
toSleep();
}
I am happy, i can light my room with the little on board led. But!
I am on windows 7, and after uploading this useful sketch, port COM is not usable. Board is detected by windows, port COM exists, but arduino 1.0.2 says that "port com is already in use" or "port com is not reachable". And I have to burn the bootloader to rescue my leonardo.
What the duck with serial on leonardo in sleep mode ?
Phil