From 01b8d29a452eb1543437c65caa1efa6813c98205 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Wed, 7 Nov 2018 19:14:59 -0700 Subject: [PATCH] Abstract relay --- firmware/firmware.ino | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/firmware/firmware.ino b/firmware/firmware.ino index 36b97b1..1732972 100644 --- a/firmware/firmware.ino +++ b/firmware/firmware.ino @@ -120,6 +120,9 @@ void greenLEDOff() { digitalWrite(GREEN_LED_PIN, LED_OFF); } void redLEDOn() { digitalWrite(RED_LED_PIN, LED_ON); } void redLEDOff() { digitalWrite(RED_LED_PIN, LED_OFF); } +void relayOn() { digitalWrite(RELAY_PIN, RELAY_CLOSED); } +void relayOff() { digitalWrite(RELAY_PIN, RELAY_OPEN); } + void processLockState() { switch (lockState) { @@ -127,7 +130,7 @@ void processLockState() greenLEDOff(); redLEDOn(); - digitalWrite(RELAY_PIN, RELAY_OPEN); + relayOff(); break; case LOCK_PREARM: if (!greenButton() && !redButton()) { @@ -141,7 +144,7 @@ void processLockState() greenLEDOff(); redLEDOn(); - digitalWrite(RELAY_PIN, RELAY_OPEN); + relayOff(); if (redButton()) { if (LOGGING) Serial.println("[INFO] Unarming interlock."); @@ -164,7 +167,7 @@ void processLockState() greenLEDOn(); redLEDOff(); - digitalWrite(RELAY_PIN, RELAY_CLOSED); + relayOn(); if (redButton()) { if (LOGGING) Serial.println("[INFO] Off button pressed.");