87. Watchdog Fundamentals

Question.2

After executing this code on an Arduino UNO, what will be the behavior of the LED?

Code

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

#define LED_PIN 12

void setup() {
  pinMode(LED_PIN, OUTPUT);
  clock_prescale_set(clock_div_16);  // Reduce system clock speed (16 MHz → 1 MHz)
  wdt_enable(WDTO_1S);               // Enable watchdog timer with a 1-second timeout
}

void loop() {
  digitalWrite(LED_PIN, LOW);
  delay(100);
  digitalWrite(LED_PIN, HIGH);
  delay(100);
  wdt_reset();  // Reset the watchdog timer
}

 

Select Answer