 
 void loop(){
   static unsigned long send_time = millis();
-  stat.pitch_pos = analogRead(potPin1);
-  stat.yaw_pos = analogRead(potPin2);
-  stat.lid_pos = analogRead(potPin3);  
-  
+  read_status();
+  
+  // read commands when we get a full line
+  if (stringComplete) {
+    read_command();
+    lcd_command();
+    do_command();
+  }
+
   //direct1 = manualSpeedControl(motorPinSpeed1, potPin1, rlyPin1, motorPinDir1, direct1, speedControl1);
   //direct2 = manualSpeedControl(motorPinSpeed2, potPin2, rlyPin2, motorPinDir2, direct2, speedControl2);
   //direct3 = manualSpeedControl(motorPinSpeed3, potPin3, rlyPin3, motorPinDir3, direct3, speedControl3);
-  
-    // print the string when a newline arrives:
-  if (stringComplete) {
-    Serial.println(inputString); 
-    // clear the string:
-    inputString = "";
-    stringComplete = false;
-  }
   
   if (millis() - send_time >= 10) {
     send_time = millis();

  }
}

void send_status() {
  statusString = "";
  statusString += "yaw_pos=" + String(stat.yaw_pos) + ";";
  statusString += "pitch_pos=" + String(stat.pitch_pos) + ";";
  statusString += "lid_pos=" + String(stat.lid_pos) + ";";
  Serial.println(statusString);
}


  int lid_pos;
};

// 0..255
struct Command {
  int yaw_pwm;
  boolean yaw_direction;
  int pitch_pwm;
  boolean pitch_direction;
  int lid_pwm;
  boolean lid_direction;
};

Status stat = { 0, 0, 0 };
Command cmd = { 0, true, 0, true, 0, true };

//serial
String inputString = "";         // a string to hold incoming data
