 
 void loop()
 {
-  double alpha = 0;
-  digitalWrite(HbridgeEnablePin, HIGH);
+  sensorValue = analogRead(analogInPin);
+  setMode();
+  computeAlphaSigned();
+  computeEnableState();
+  computeLogicState();
   
-  alpha = computeLogicState();
-  if (isCycleStarting)
-  {
-    if ((millis()-initialTime) > minTime_ms)
-    { 
-      isCycleStarting = false;
-    } 
-     Serial.println("isStarting");
-  }
-  else
-  {
-    if ((millis() - initialTime) < minTime_ms/alpha*(1-alpha)+minTime_ms)
-    {
-          digitalWrite(HbridgeEnablePin, LOW);
-          Serial.println("isNotStarting");
-    }
-    else
-    {
-      initialTime = millis();
-      isCycleStarting = true;
-    } 
-  }
-  alpha = computeLogicState();
   delay(1);
 
 

    else
    {
      // Brake ?
      digitalWrite(HbridgeLogicPin1, LOW);
      digitalWrite(HbridgeLogicPin2, LOW);
    }
	// \todo: add an input to enable manual rotation of the motor
  }
  return alpha;
}





//  Serial.print("alphaManual = " );                       
//  Serial.print(alphaSigned);      
//  Serial.print("\t alphaUsed = ");      
 Serial.println(alphaSigned);   
}
void setMode()
{  
  // If the analog value is changed, it means that the user wants to take control with the joystick
  // so fallback to joystick control
  if (fabs(initialSensorValue-sensorValue) > 10)
