A watchdog timer is a software mechanism that monitors the microcontroller’s operation. If the MCU stops responding or gets stuck, the watchdog timer triggers a reset, helping prevent runaway behavior.
Software can freeze due to:
Without a watchdog timer, a stuck MCU might leave motors running uncontrolled. A watchdog timer ensures that software failures result in a safe reset instead of a runaway robot.
MCU sets up a timer that must be regularly reset (“kicked”) during normal operation. If the timer expires, it assumes the software is stuck and resets the MCU. Most microcontrollers have built-in watchdog timers that are easy to enable.
Example (conceptual):
void loop() {
// Normal robot logic
resetWatchdogTimer(); // Kick the watchdog
}