Why wont the watchdog setup work based on the following code?
1st thing I do (at present) is bring the reset PIN to high to avoid reset loop.
2nd thing I do define "startMillis" by taking a read of millis().
Further down and within the "While" I then take a further reading of millis() and define "currentMillis" and finally if (currentMillis - startMillis >= startupPeriod) then digitalWrite(testPin, LOW).
Cant work out why this isn't working.
My aim as you have all suggested is to reset the board if the Arduino stays in the while loop for to much time.
void setup() {
digitalWrite(testPin, HIGH);
// Start Timeout Timer
startMillis = millis();
// initialize the LED pins as an output
pinMode(readyPin, OUTPUT);
pinMode(failPin, OUTPUT);
pinMode(callPin, OUTPUT);
pinMode(testPin, OUTPUT);
// initialize the pushbutton pin as an input
pinMode(buttonPin, INPUT);
// connection state
boolean notConnected = true;
// Start GSM shield
// If your SIM has PIN, pass it as a parameter of begin() in quotes
while(notConnected==true){
digitalWrite(failPin, HIGH);
if(gsmAccess.begin(PINNUMBER)==GSM_READY)
{ notConnected = false;
digitalWrite(failPin, LOW);
digitalWrite(readyPin, HIGH);}
currentMillis = millis();
if (currentMillis - startMillis >= startupPeriod)
digitalWrite(testPin, LOW);
}}