     Serial.println(degC);
   }
   else if (cmd == "VERSION") {
-    Serial.println("TC Laboratory Firmware Version " + vers);
+    Serial.println("TClab Firmware Version " + vers);
   }
   // shutdown
-  else if (cmd == "X") {
-    analogWrite(pinQ1, 0);
-    analogWrite(pinQ2, 0);
+  else if ((cmd == "X") or (cmd.length() > 0)) {
+    Serial.println("Unrecognized command. Please reset.");
+    setHeater1(0);
+    setHeater2(0);
+    brdStatus = 0;
   }
-  // shut down on unrecognized command
-  else if (cmd.length() > 0) {
-    Serial.println("Unrecognized command. Please reset.");
-    analogWrite(pinQ1, 0);
-    analogWrite(pinQ2, 0);
-    while (true) {
-      analogWrite(pinLED1, limLED1);
-      delay(250);
+}
+
+// check alarms and update status on LED1
+void AlarmCheck(void) {
+  if (analogRead(pinT1) > limT1) {
+    alarmStatus = 1;
+  }
+  else if (analogRead(pinT2) > limT2) {
+    alarmStatus = 1;
+  }
+  else {
+    alarmStatus = 0;
+  }
+}
+
+// update LED
+void LEDUpdate(void) {
+  // find led status
+  ledStatus = brdStatus;
+  if ((Q1 > 0) or (Q2 > 0)) {
+    ledStatus = 2;
+  }
+  if (alarmStatus > 0) {
+    ledStatus = 3;
+    if ((Q1 > 0) or (Q2 > 0)) {
+      ledStatus = 4;
+    }
+  }
+  // update led depending on ledStatus
+  if (ledStatus == 0) {
+    analogWrite(pinLED1, 0);
+  }
+  else if (ledStatus == 1) {
+    analogWrite(pinLED1, loLED);
+  }
+  else if (ledStatus == 2) {
+    analogWrite(pinLED1, hiLED);
+  }
+  else if (ledStatus == 3) {
+    if ((millis() % 2000) > 1000) {
+      analogWrite(pinLED1, loLED);
+    } else {
       analogWrite(pinLED1, 0);
-      delay(250);
+    }
+  }
+  else if (ledStatus == 4) {
+    if ((millis() % 2000) > 1000) {
+      analogWrite(pinLED1, hiLED);
+    } else {
+      analogWrite(pinLED1, 0);
     }
   }
 }
 
-
-// check alarms and update status on LED1
-void AlarmsCheck(void) {
-  if ((analogRead(pinT1) > limT1) or (analogRead(pinT2) > limT2)) {
-    analogWrite(pinLED1,limLED1);
-  } else {
-    analogWrite(pinLED1,limLED1/16);
-  }
-}
-
-
-// setup on reboot
+// arduino setup procedure
 void setup() {
   analogReference(EXTERNAL);
   Serial.begin(baud); 

    ; // wait for serial port to connect.
  }
  Serial.flush();
  analogWrite(pinQ1,0);
  analogWrite(pinQ2,0);
}


// main event loop
void loop() {
  SerialParse();
  CommandDispatch();
  AlarmsCheck();
}

  This firmware is initially loaded into the Temperature Control Laboratory Arduino. 
  The firmware scans the serial port looking for case-insensitive commands:

  Q int     set Heater 1 and 2, range 0 to 255, subject to limits
  Q1 int    set Heater 1, range 0 to 255 subject to limit
  Q2 int    set Heater 2, range 0 to 255 subject to limit
  T1        get Temperature T1, returns deg C as string
  T2        get Temperature T2, returns dec C as string
  VERSION   get firmware version string
  X         shutdown, reset required

  LED1 on dim during normal operation.
  LED1 on bright when if either is on
  LED1 blinks if high temperature alarm is on

  Receipt of any unrecognized commands cause the board to shutdown and  Reset is required.
*/

// global variables
char Buffer[64];               // buffer for parsing serial input
String cmd;                    // command 
int pv;                        // command pin value
int ledStatus;                 // 0:off, 1:dim, 2:bright 3:dim blink 4:bright blink
int brdStatus = 1;             // board status 0:reset required 1:ok
int Q1 = 0;                    // last value written to Q1 pin
int Q2 = 0;                    // last value written to Q2 poin
int alarmStatus = 0;           // hi temperature alarm status

// constants
const String vers = "0.1";     // version of this firmware
