Hello,
I'm newbie with the arduino and with the electronics. But I try to do some projects with my new arduino.
I'm trying to put the arduino to sleep so that his timer0 will stay working and millis() will count. I try to use SLEEP_MODE_IDLE sleep mode, but without big success. I have an arduino standalone on a breadboard and a LED attached to arduino pin 13 (pin 19 on Atmega328). When I execute the code which hate to put arduino on sleep nothing happens. The LED continue to blink and the current consumption is the same.
Here is my sleepNow() function:
void sleepNow()
{
set_sleep_mode(SLEEP_MODE_IDLE); // sleep mode is set here
sleep_enable();
attachInterrupt(0,wakeUpNow, LOW);
power_adc_disable();
power_spi_disable();
//power_timer0_disable(); //millis() clock
power_timer1_disable();
power_timer2_disable();
power_twi_disable();
sleep_mode();
//Wake up
sleep_disable();
power_adc_enable();
power_spi_enable();
power_timer1_enable();
power_timer2_enable();
power_twi_enable();
detachInterrupt(0);
}
If I uncomment the line
//power_timer0_disable(); //millis() clock
arduino is going to sleep, but in this case millis() are not working.
I'm using 12V DC with 7805 regulator. Here are my current measurements on +12V line:
7805 itself is using round 5 mA
LED ON - round 29 mA
LED OFF - 21 mA
After sleepNow() is called the current remain the same. If I uncomment the line
//power_timer0_disable(); //millis() clock
when arduino sleeps the consumption is round 11 mA.
Can you help me and tell me what I'm doing wrong and what exactly have to do to put arduino on sleep in SLEEP_MODE_IDLE and millis() function to work?