Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save desireesantos/e22d09dc91140acd4b901050b8d507a7 to your computer and use it in GitHub Desktop.
Save desireesantos/e22d09dc91140acd4b901050b8d507a7 to your computer and use it in GitHub Desktop.
WatchDog solution to reset arduino every 4 seconds
#include <avr/wdt.h>
void setup() {
//Reset arduino every 4 seconds WDTO_4S
//https://www.nongnu.org/avr-libc/user-manual/group__avr__watchdog.html#ga9e52c54d10b6a6a7ce04aaaa4abea51f
wdt_enable(WDTO_4S);
Serial.begin(9600);
}
void loop() {
// wdt_reset(); If you want to reset the timer to zero, just call this function
for(int i=0; i<=1000; i++){
Serial.println(i);
delay(50);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment