   
   // separate command from associated data
   int idx = read_.indexOf(sp);
-  String cmd = read_.substring(0,idx);
+  cmd = read_.substring(0,idx);
   cmd.trim();
   cmd.toUpperCase();
 
   // extract data. toInt() returns 0 on error
   String data = read_.substring(idx+1);
   data.trim();
-  int pv = data.toInt();
-  
+  pv = data.toInt();
+}
+
+
+// dispatch commands
+void CommandDispatch(void) {
   // process commands
-  if (cmd == "LED1") {
-    analogWrite(pinLED1, max(0,min(limLED1,pv)));
-  }
-  else if (cmd == "Q") {
+  if (cmd == "Q") {
     analogWrite(pinQ1, max(0,min(limQ1,pv)));
     analogWrite(pinQ2, 0);
   }

  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, set LED1, Q1, Q2 to zero

  LED1 is on during normal operation.


const int limT1   = 310;       // T1 high alarm (approx. 50 deg C)
const int limT2   = 310;       // T2 high alarm (approx. 50 deg C)


// parse serial input
void SerialParse(void) {
  // read serial input
  int ByteCount = Serial.readBytesUntil(nl,Buffer,sizeof(Buffer));
  String read_ = String(Buffer);
