 
         if (command == "light red") {
             lightPinExclusive(RED_PIN);
-            flashingPin = -1;
         }
         else if (command == "light yellow") {
             lightPinExclusive(YELLOW_PIN);
-            flashingPin = -1;
         }
         else if (command == "light green") {
             lightPinExclusive(GREEN_PIN);
-            flashingPin = -1;
         }
         else if (command == "flash red") {
-            lightPinExclusive(-1);
-            flashingPin = RED_PIN;
+            flashPinExclusive(RED_PIN);
         }
         else if (command == "flash yellow") {
-            lightPinExclusive(-1);
-            flashingPin = YELLOW_PIN;
+            flashPinExclusive(YELLOW_PIN);
         }
         else if (command == "flash green") {
-            lightPinExclusive(-1);
-            flashingPin = GREEN_PIN;
+            flashPinExclusive(GREEN_PIN);
         }
         else if (command == "lights off") {
-            lightPinExclusive(-1);
-            flashingPin = -1;
+            lightPinExclusive(VOID_PIN);
         }
     }
 }
 
 void lightPinExclusive(int pin) {
+    flashingPin = VOID_PIN;
+    
     for (int i = 0; i < pinCount; i++) {
         digitalWrite(pins[i], pins[i] == pin ? HIGH : LOW);
     }
 }
+
+void flashPinExclusive(int pin) {
+    lightPinExclusive(pin);
+    
+    flashingPin = pin;
+    flashingHigh = true;
+    flashStartTime = millis();
+}
+

const int YELLOW_PIN = 3;
const int GREEN_PIN = 2;

const int pins[] = { RED_PIN, YELLOW_PIN, GREEN_PIN };
const int pinCount = sizeof(pins) / sizeof(int);

int flashingPin = -1;

void setup() {
    Serial.begin(9600);


void loop() {
  
    if (flashingPin != VOID_PIN) {
        if ((millis() - flashStartTime) >= flashDuration) {
            flashingHigh = !flashingHigh;
            flashStartTime = millis();
            
            digitalWrite(flashingPin, flashingHigh);
        }
    }

    if (Serial.available()) {
