   //  attachInterrupt(switchTriggerIRQ, switchTriggerInterrupt, FALLING);
 
   digitalWrite(statusLED, LOW);
+
+  // reset device if loop() takes too long
+  wdt_enable(WDTO_120MS);
 }
 
 
 void loop() {
   unsigned long currentMillis;
   unsigned long elapsedMillis;
+
+  wdt_reset();
 
   currentMillis = millis();
   // millis() will overflow after approximately 50 days.

        }
      }
      // hold the door open if button pressed
      // TODO: another possibility would be to fall-through to doorBlocked
      // and close the door instead. which way is better?
      if (swTrigger == LOW) {
        motorFree();
        debug(currentMillis, F("Button switch triggered - door blocked\r\n"));



void setup() {
  wdt_disable();

  pinMode(statusLED, OUTPUT);
  digitalWrite(statusLED, HIGH);

