AVR Library

Thank you all for the help. Attached is an example sketch, and here it is in-line. If I comment out the WDT bits, the sketch works fine. It will not compile do to errors around the wdt_enable and wdt_Rest() functions. It seems to not be properly picking up the avr.h from the include, and thus every function or constant defined by it are "not declared in this scope". My guess is the installation of aruido ide I did is balled up - that somehow the directory structure it assumes doesn't match what I have? Is that possibly it?

The output of verify (verbose=true) is:
sketch_wdt_example.ino:1:10: error: #include expects "FILENAME" or
sketch_wdt_example.ino: In function 'void setup()':
sketch_wdt_example:23: error: 'WDTO_8S' was not declared in this scope
sketch_wdt_example:23: error: 'WDT_enable' was not declared in this scope
sketch_wdt_example.ino: In function 'void loop()':
sketch_wdt_example:44: error: 'wdt_reset' was not declared in this scope

#include (avr/wdt.h)
// Test program for the WDT on an UNO
// Ramps up an LED, then down in sawtooth fashon in 102 steps. Delay between
// steps can be chosen to let the cycles proceed, or if 102 x delay exceeds
// WDT the timer should restart the MPU.
// Uncomment the lines for wdt_enable(WDTO_8), wdt_reset() to try WDT, leave
// comments in to test sketch works fine without the WDT enabled.

/*
Fading modified to ramp up an LED over time, which will be interrupted eventually
by WDT resetting the machine and starting over, ML Workman 5/2014

The circuit:

  • LED attached from digital pin 9 to ground.

Adapted from David A. Mellis Fading (modified 30 Aug 2011 By Tom Igoe)

*/

int ledPin = 9; // LED connected to digital pin 9
int delay_between_steps = 100; // Adjust this to fit or exceed WDT delay (8s)
void setup() {
WDT_enable(WDTO_8S); // Enable WDT when un-commented
Serial.begin(9600); // open the serial port at 9600 bps
Serial.print("....starting up"); //
}

void loop() {
// fade in from min to max in increments of 5 points:
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
// sets the value (range from 0 to 255):
analogWrite(ledPin, fadeValue);
// wait for 100 milliseconds to see the dimming effect
delay(100);
}

// fade out from max to min in increments of 5 points:
for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
// sets the value (range from 0 to 255):
analogWrite(ledPin, fadeValue);
// wait for 100 milliseconds to see the dimming effect
delay(100);
}
wdt_reset(); // Uncommented, this should reset the WDT. Since the timer is 8 seconds
// and the previous loops take about 10, this should cause us to restart
// of the fade up and fade down of the LED.
}

sketch_wdt_example.ino (1.88 KB)