Hello
I want to make arduino sleep for 5minutes(or more) and wake up! and sleep again...
I found an example as below and is implemented very well. but I don't know how to change time which is sat 8 seconds.
help me to change time
setup(){
/*** Setup the WDT ***/
/* Clear the reset flag. */
MCUSR &= ~(1<<WDRF);
/* In order to change WDE or the prescaler, we need to
* set WDCE (This will allow updates for 4 clock cycles).
*/
WDTCSR |= (1<<WDCE) | (1<<WDE);
/* set new watchdog timeout prescaler value */
WDTCSR = 1<<WDP0 | 1<<WDP3; /* 8.0 seconds */
/* Enable the WD interrupt (note no reset). */
WDTCSR |= _BV(WDIE);
}
void loop(){
if(f_wdt == 1)
{
/* Toggle the LED */
digitalWrite(LED_PIN, !digitalRead(LED_PIN));
delay(2);
Serial.println("waked up! and sleep for 8 sec");
delay(2);
/* Don't forget to clear the flag. */
f_wdt = 0;
/* Re-enter sleep mode. */
enterSleep();
}
else
{
/* Do nothing. */
}
}
8 seconds is the max value supported by hardware. For longer timeouts, you will need to add some loop that counts watchdog timeouts until enough of them have passed to equal your total timeout.