#include<avr/sleep.h>
ISR(TIMER1_OVF_vect)
{
static boolean state=false;
Serial.println("Woke from sleep mode");
if(state)
{
state=false;
digitalWrite(13,LOW);
}
else
{
state=true;
digitalWrite(13,HIGH);
}
TIFR1=0x00;
}
void setup()
{
pinMode(13,OUTPUT);
TCCR1A=0x00;
TCCR1B=0x05;
TIFR1=0x00;
TIMSK1=0x01;
Serial.begin(9600);
MCUCR|=0xF0;
}
void loop()
{
Serial.println("Going to sleep mode");
sleep_cpu();
}
and
#include<avr/sleep.h>
ISR(TIMER1_OVF_vect)
{
static boolean state=false;
//Serial.println("Woke from sleep mode");
if(state)
{
state=false;
digitalWrite(13,LOW);
}
else
{
state=true;
digitalWrite(13,HIGH);
}
TIFR1=0x00;
}
void setup()
{
pinMode(13,OUTPUT);
TCCR1A=0x00;
TCCR1B=0x05;
TIFR1=0x00;
TIMSK1=0x01;
// Serial.begin(9600);
MCUCR|=0xF0;
}
void loop()
{
// Serial.println("Going to sleep mode");
sleep_cpu();
}
actually the first program doesnt work in sleep mode, it always prints the data "going to sleep mode" and prints "woke from sleep mode" after every 4 seconds..
I'm finding it hard to figure out why its not working when i use serial port communications..