86. Watchdog Operation

Question.3

Consider the following Arduino UNO code that uses the Watchdog Timer.
What will be printed on the Serial Monitor?

#include <avr/wdt.h>
#include <avr/interrupt.h>

void setup() {
  Serial.begin(115200);
  delay(100);

  wdt_enable(WDTO_1S); // Enable watchdog timer with a 1-second timeout

  sei(); // Enable global interrupts

  Serial.println("System started");
}

ISR(WDT_vect) {
  Serial.println("Watchdog Interrupt Triggered");
}

void loop() {
  WDTCSR |= (1 << WDIE); 
  Serial.println("Loop running");
  delay(2000); // Longer than watchdog timeout
  wdt_reset(); // Reset watchdog timer
}

 

 

Select Answer