Hello,
I have been trying to get something working most of the weekend but no joy.
I want to put my system to sleep, to save power, but I think the best thing to do might be to use the WDT, and maybe wake up every second or so, and see if I am receiving information on an analog pin from a FSR.
So far I have
#include <avr/wdt.h>
void setup()
{
Serial.begin(9600);
}
void wdtSetup(void)
{
cli(); //Disable all interrupts
wdt_reset(); //Reset the WDT
/*
WDTCSR configuration
WDIE = 1: Interrupt enable
WDE = 1: Reset enable
WDP3:1 = '0110': 1 sec time-out
*/
//Enter WDT config mode
WDTCSR |= (1<<WDCE) | (1<<WDE);
//WDT Settings
WDTCSR = (1<<WDIE)|(1<<WDE)|(0<<WDP3)|
(1<<WDP2)|(1<<WDP1)|(0<<WDP0);
sei();
}
void loop()
{
Serial.println("...");
}
I got help with this code from searching the site here. But now I am kinda stuck. I am not sure who I actually get the WDT going! Do I need to call a sleep function and then the WDT will wake up every second? Also, when I don't want the system to sleep (i.e. when it is receiving data) do I disable interrupts?
I really am just stumbling around in the dark here, so if someone has a flashlight, that would be great!! (Man, that was a crap analogy, sorry!).
Thanks in advance.
Seán