#define LIMIT_CLOSED_PIN 19 // A5: limit switch for close
#define AJAR_PIN 14 // input pin for reed relais (door ajar/shut)
-boolean ajar_last_state = false;
+#define SHUT 0
+#define AJAR 1
+byte ajar_last_state = SHUT;
#define MANUAL_OPEN_PIN 12 // keys for manual open and close
#define MANUAL_CLOSE_PIN 13 //
//**********//
-boolean get_ajar_status() // shut = true, ajar = false
+byte get_ajar_status()
{
- return (digitalRead(AJAR_PIN) == LOW);
+ if(digitalRead(AJAR_PIN) == LOW)
+ return SHUT;
+
+ return AJAR;
}
void init_ajar()
else if(is_closed())
Serial.print("closed");
Serial.print(", idle");
- if(get_ajar_status())
+ if(get_ajar_status() == SHUT)
Serial.println(", shut");
else
Serial.println(", ajar");
case WAIT: Serial.print(", waiting"); break;
default: Serial.print(", <undefined state>"); break;
}
- if(get_ajar_status())
+ if(get_ajar_status() == SHUT)
Serial.println(", shut");
else
Serial.println(", ajar");
PORTD = LEDS_ON;
}
}
- boolean a = get_ajar_status();
- if (a != ajar_last_state)
+ byte a = get_ajar_status();
+ if(a != ajar_last_state)
{
print_status();
ajar_last_state = a;