Loading
Loading
IoT Lab content is currently available in Arabic only. We're working on an English version.
عرض بالعربية →How to rescue the robot if the code completely freezes — without human intervention.
#include <avr/wdt.h>
void setup() {
Serial.begin(9600);
wdt_enable(WDTO_2S); // عداد لثانيتين
}
void loop() {
wdt_reset(); // يجب تصفير العداد قبل مرور ثانيتين
// إذا وضعنا هنا delay(3000) سيعيد الأردوينو التشغيل فوراً
}Enabling the Watchdog with a very short period and using a long delay() in setup() — the Arduino will get stuck in an infinite reboot loop the moment it's programmed.