My arduino is having difficulty going to sleep.
I am using avr sleep
In my code it tells the cpu to go to sleep when it sees a HIGH on pin 11.
If i use SLEEP_MODE when it sees pin 11 go HIGH it turns on the led i have attached to pin 10 and it does not go to sleep.
If i use SLEEP_CPU instead of SLEEP_MODE the led doesn't turn on and the cpu will go to sleep sometimes.
But if i tell the led to turn on and then off as soon as it is told to go to sleep then the cpu goes to sleep every time.
You need to post your actual code. Use code tags around the code - the </> in the post edit controls.
This is the code that the cpu will go to sleep.
void sleepNow()
{
digitalWrite(ledPin, LOW);
delay(100);
digitalWrite(ledPin, HIGH);
delay(100);
digitalWrite(ledPin, LOW);
delay(100);
digitalWrite(ledPin, HIGH);
delay(100);
digitalWrite(ledPin, LOW);
set_sleep_mode(SLEEP_MODE_STANDBY);
sleep_enable();
attachInterrupt(0, wakeUpNow, LOW);
// PROGRAM SLEEPS HERE
sleep_cpu();
// PROGRAM CONTINUES FROM HERE AFTER WAKING UP
sleep_disable();
detachInterrupt(0);
}
If i dont have the first section to turn the led on and off the cpu will sometimes go to sleep.
If i replace sleep_cpu with sleep_mode it turn the led attached to pin 6 on when told to go to sleep
system
4
Your code does not compile and lacks code tags.