daily pastebin goal
57%
SHARE
TWEET

Untitled

a guest Dec 13th, 2018 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<avr/wdt.h> /* Header for watchdog timers in AVR */
  2.  
  3. void setup() {
  4.     Serial.begin(9600); /* Define baud rate for serial communication */
  5.     Serial.println("Watchdog Demo Starting");
  6.     pinMode(13, OUTPUT);
  7.     wdt_disable();  /* Disable the watchdog and wait for more than 2 seconds */
  8.     delay(3000);  /* Done so that the Arduino doesn't keep resetting infinitely in case of wrong configuration */
  9.     wdt_enable(WDTO_2S);  /* Enable the watchdog with a timeout of 2 seconds */
  10. }
  11.  
  12. void loop() {
  13.     for (int i = 0; i<20; i++) /* Blink LED for some time */
  14.     {
  15.         digitalWrite(13, HIGH);
  16.         delay(100);
  17.         digitalWrite(13, LOW);
  18.         delay(100);
  19.         wdt_reset();  /* Reset the watchdog */
  20.     }
  21.     while (1); /* Infinite loop. Will cause watchdog timeout and system reset. */
  22. }
  23.    
  24. Opening port
  25. Port open
  26. Watchdog Demo StartWatchdog Demo StartWatchdog Demo StartWatchdog Demo StartWatchdog Demo StartWatchdog
  27. Demo StartWatchdog Demo StartWatchdog Demo StartWatchdog Demo StartWatchdog Demo Start
  28. Port closed
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top