   }
   else
   {
-   if (inputString == "o")
-   {
-     isSerialControl = false;
-   }
-   else
-   {
-     // To reject incorrect value due to 0. badly read
-     if ((StrToFloat(inputString)>=-1) & (StrToFloat(inputString)<=1))
-     {
-       alphaSigned = StrToFloat(inputString);
-       lastSerialInputTime = millis();
-       //Serial.println(alphaSigned);
-     }
-   }
-  }
-  //Serial.println(inputString);
-  inputString="";
+    if (inputString == "o")
+    {
+      isSerialControl = false;
+    }
+    else
+    {
+      char c[50];
+      inputString.toCharArray(c, 50);
+      char *gpsStream = c;
+      while (*gpsStream)
+        if (nmea.encode(*gpsStream++));
+      { 
+        alphaSigned = StrToFloat(pwm.value()); 
+        lastSerialInputTime = millis();
+      }
+    }
+  }  
 }
+
 
 void loop()
 {
+  SerialEvent();
   int power;
   sensorValue = analogRead(analogInPin);
   setMode();
   computeAlphaSigned();
-  
   power = alphaSigned*127;
   ST.motor(1, power);
-  delay(20);
+  delay(10);
+  if (millis()-lastWriteTime>100)
+  {
+    lastWriteTime = millis();
+    Serial.println(alphaSigned);
+    if (isSerialControl)
+    {
+      Serial.println("S");
+    }
+    else
+    {
+      if (isManualControl)
+      {
+        Serial.println("M");
+      }
+    }
+
+  }
+  Serial.flush();
 }
 
 void setMode()


#include <SoftwareSerial.h>
#include <SabertoothSimplified.h>

SoftwareSerial SWSerial(NOT_A_PIN, 8); // RX on no pin (unused), TX on pin 11 (to S1).
SabertoothSimplified ST(SWSerial); // Use SWSerial as the serial port.

double deadBand = 0.1; // Use to ensure zero speed. Should not be zero
double serialFrequency = 0;
long lastSerialInputTime = 0;
long lastWriteTime = 0;

TinyGPSPlus nmea;
TinyGPSCustom pwm(nmea, "ORPWM", 1); // $GPGSA sentence, 15th element


void setup()
{
  // Initialize software serial communication with Sabertooth 
  SWSerial.begin(9600);
  // Initialize serial communications at 9600 bps:
  Serial.begin(19200);
}

void SerialEvent() {

  inputString="";
  Serial.flush();
  while (Serial.available()) {
    // Get the new byte:
