basic commands

This commit is contained in:
Matthew Frost 2023-10-30 16:38:56 +01:00
parent 853389266f
commit 7e9d7e96ea

View file

@ -7,11 +7,15 @@ const unsigned long displayDelay = 1000; // Delay in milliseconds after which th
unsigned int bitCount = 0; // Variable to keep track of the bit count
unsigned int maxReaderWaitTime = 9000; // Variable to timeout reader after too long of no data.
void commandLockDoor() {
// Add code to lock the door here (e.g., activate a relay, if applicable)
Serial.println("DOOR_STATUS: locked");
}
void commandUnlockDoor() {
// Add code to unlock the door here (e.g., deactivate a relay, if applicable)
Serial.println("DOOR_STATUS: unlocked");
}
void handleInterrupt(int bitValue) {
static unsigned long lastInterruptTime = 0;
@ -71,11 +75,9 @@ void setup() {
digitalWrite(ALARM_PIN, HIGH); // Do not set to low or it will constantly beep.
#endif
}
void loop() {
// Check if new data is available
@ -108,7 +110,7 @@ void loop() {
#endif
String fullCardID = String(facilityID)+":"+String(cardID);
Serial.print("FULL-CARD-ID: ");
Serial.print("FULL_CARD_ID: ");
Serial.println(fullCardID);
@ -123,4 +125,19 @@ void loop() {
bitCount = 0; // Reset the bit count
}
// Check for commands from the serial interface
if (Serial.available() > 0) {
String command = Serial.readString();
command.trim();
if (command.equals("unlock")) {
commandUnlockDoor();
} else if (command.equals("lock")) {
commandLockDoor();
}
}
}