   // Note that AccelStepper.disableOutputs doesn't seem to work
   // correctly when pins are inverted and leaves some outputs on.
   if (stepperL.distanceToGo() == 0 && stepperR.distanceToGo() == 0) {
-      digitalWrite(motorLPin1, LOW);
-      digitalWrite(motorLPin2, LOW);
-      digitalWrite(motorLPin3, LOW);
-      digitalWrite(motorLPin4, LOW);
-      digitalWrite(motorRPin1, LOW);
-      digitalWrite(motorRPin2, LOW);
-      digitalWrite(motorRPin3, LOW);
-      digitalWrite(motorRPin4, LOW);
+    
+    if (isQEmpty()) {
+      
+      // check the text writing buffer
+      if (text.length() > 0) {
+        char c = text[0];
+        text = text.substring(1);  // lose the first character 
+        writeChar(c);
+        
+      } else {
+        // take a breather
+        digitalWrite(motorLPin1, LOW);
+        digitalWrite(motorLPin2, LOW);
+        digitalWrite(motorLPin3, LOW);
+        digitalWrite(motorLPin4, LOW);
+        digitalWrite(motorRPin1, LOW);
+        digitalWrite(motorRPin2, LOW);
+        digitalWrite(motorRPin3, LOW);
+        digitalWrite(motorRPin4, LOW);
+      }
+    } else {
+      // pop and process next command from queue
+      doLogoCommand(popCmd());
+    }
   }
 }
 
-void doLogoCommand(String cmd)
-{
+void doLogoCommand(String c)
+{
+  
+  Serial.println(c);
   /* Official Logo Commands
        Implemented
          -FD, BK, LT, RT
        Todo
          -PU - Pen Up
          -PD - Pen Down
-         -ARC
+         -ARC 
    */  
   /* Unofficial extensions
       BZ n - sound buzzer for n milliseconds

  pinMode(buzzer, OUTPUT);
  
  buzz(250);
}

int progStep = 0;

String cmd;

void loop()
{
  // Process Logo commands from Serial
  if (Serial.available()) {
    char c = Serial.read();
    if (c == '\r' || c == '\n') {
      if (cmd != "") {
        Serial.println("OK:" + cmd);
        doLogoCommand(cmd);
        cmd = "";
      }
    } else {
      cmd += c;
    }
  }

  // Check bump switches
  if (!digitalRead(switchFL) || !digitalRead(switchFR)) {
    buzz(250);
    stepperL.stop();
    stepperR.stop();
  }
    
  // Do buzzer

      SIG - sign Logobots name
    */  
  
  if (c.startsWith("TO")) {
    // split out x and y co-ordinates
    int sp = c.indexOf(" ",3);
    int x = c.substring(3,sp).toInt();
    int y = c.substring(sp+1).toInt();
    driveTo(x,y);
  } else if (c.startsWith("FD")) {
    int dist = c.substring(3).toInt();
    drive(dist);
  } else if (c.startsWith("BK")) {
    int dist = c.substring(3).toInt();
    drive(-dist);
  } else if (c.startsWith("RT")) {
    int angle = c.substring(3).toInt();
    turn(-angle);
  } else if (c.startsWith("LT")) {
    int angle = c.substring(3).toInt();
    turn(angle);
  } else if (c.startsWith("ST")) {
    stepperL.stop();
    stepperR.stop();
  } else if (c.startsWith("BZ")) {
    buzz(c.substring(3).toInt());
  } else if (c.startsWith("PU")) {
    penUp();
  } else if (c.startsWith("PD")) {
    penDown();
  } else if (c.startsWith("SIG")) {
    writeLogobot();
  } else if (c.startsWith("WT")) {
    writeText(c.substring(3));
  }
}

