//**********//
-void init_ajar()
+boolean get_ajar_status() // shut = true, ajar = false
{
- pinMode(AJAR_PIN, INPUT); // set pin to input
- digitalWrite(AJAR_PIN, HIGH); // turn on pullup resistors
- ajar_last_state = digitalRead(AJAR_PIN);
+ return (digitalRead(AJAR_PIN) == LOW);
}
-boolean get_ajar_status() // shut = true, ajar = false
+void init_ajar()
{
- if(digitalRead(AJAR_PIN))
- return false;
-
- return true;
+ pinMode(AJAR_PIN, INPUT); // set pin to input
+ digitalWrite(AJAR_PIN, HIGH); // turn on pullup resistors
+ ajar_last_state = get_ajar_status();
}
//**********//
}
}
boolean a = get_ajar_status();
- if(a != ajar_last_state)
+ if (a != ajar_last_state)
+ {
print_status();
- ajar_last_state = a;
+ ajar_last_state = a;
+ }
}