Arduino watchdog timer Julian Rogers Home Home

Watchdog timer 2

//Watchdog timer - reset when LED stops flashing

void setup() {

// initialize digital pin 13 as an output.

  pinMode(13, OUTPUT);

}

void loop() {

  for(int i = 1; i < 100; i++ ){

    digitalWrite(13, HIGH);   // turn the LED on

    delay(100);              // wait for a second

    digitalWrite(13, LOW);    // turn the LED off

    delay(100);

    }

  while(true){

  }   

}

//Watchdog timer - self reset.

void setup() {

  // initialize digital pin 13 as an output.

  pinMode(13, OUTPUT);

  pinMode(7, OUTPUT);

}

void loop() {

  for(int i = 1; i < 50; i++ ){

  digitalWrite(13, HIGH);   

  delay(100);              

  digitalWrite(13, LOW);   

  delay(100);

  }

  delay(1000);

  //if pin 7 is connected to reset via an NPN transistor,

  //the Arduino should reset itself

  digitalWrite(7, HIGH);  

  while(true){

  }   

}

This program simulates an Arduino hangup.

This program allows the Arduino to reset itself when, in this case, pin 7 is made to go high.

I often plan the PCB layout on paper.

PCB designed using Design Spark

PCB manufactured

Test setup for prototype

Test Software

Note

I fitted a switch to the watchdog timer as I wasn’t sure what would happen when I downloaded a program to the Arduino and the watchdog was running.

Building and testing