diff --git a/chicken_door.ino b/chicken_door.ino index db8a811..3c69ae5 100644 --- a/chicken_door.ino +++ b/chicken_door.ino @@ -30,7 +30,8 @@ #define BRIGHTNESS_SIZE 3 #define BRIGHT_THRESHOLD 600 -#define OPEN_DELAY 6250 +#define OPEN_DELAY 6500 +#define MAX_CLOSE_TIME 7500 #define HYSTERESIS 50 word brightness[BRIGHTNESS_SIZE]; @@ -71,12 +72,15 @@ } */ void raiseDoor() { + long millisLeft = MAX_CLOSE_TIME; digitalWrite(TEMP_SUPPLY_PIN, HIGH); digitalWrite(FWREV_PIN, LOW); delay(100); + millisLeft -= 100; digitalWrite(ONOFF_PIN, HIGH); - while (digitalRead(DOOR_CONTACT_PIN) == LOW) { + while ((digitalRead(DOOR_CONTACT_PIN) == LOW) && (millisLeft > 0)) { delay(100); + millisLeft -= 100; } delay(200); digitalWrite(ONOFF_PIN, LOW);