   }
       
   if( HasCrossedTime(c1) ){
-      pf.single_pwm(TURN,m1);
+    move1();
   }
   if( HasCrossedTime(c2) ){
-      pf.single_pwm(TURN,m2);
+    move2();
   }
   
   if( HasCrossedTime(c3) ){
-      pf.single_pwm(TURN,m3);
+    move3();
   }
  
   if( HasCrossedTime(c4) ){
-      pf.single_pwm(TURN,m4);
+    move4();
   }
  
   if( HasCrossedTime(c5) ){
-      pf.single_pwm(TURN,m5);
+    move5();
   }
  
   if( HasCrossedTime(c6) ){
-      pf.single_pwm(TURN,m6);
+    move6();
   }
  
   if( HasCrossedTime(c7) ){
-      pf.single_pwm(TURN,m7);
+    move7();
   }
  
    delay(10); 
 }
 
-unsigned long lapCompensate(unsigned long time){
-  return time * lastLapTime / baseLapTime;
+void move1(){
+    fullLeft(); //PWM_REV6
+}
+
+void move2(){
+  pf.single_pwm(TURN,PWM_BRK);
+}
+
+void move3(){
+  pf.single_pwm(TURN,PWM_FWD6);
+}
+
+void move4(){
+  pf.single_pwm(TURN,PWM_REV6);
+}
+
+void move5(){
+  pf.single_pwm(TURN,PWM_BRK);
+}
+
+void move6(){
+    fullRight();  //PWM_FWD6 
+}
+
+void move7(){
+  pf.single_pwm(TURN,PWM_BRK);  //
+}
+
+void fullLeft(){
+      pf.single_pwm(TURN,PWM_REV6);
+      pf.single_increment(TURN,false);
+}
+
+void fullRight(){
+      pf.single_pwm(TURN,PWM_FWD6);
+      pf.single_increment(TURN,true);
+}
+
+unsigned long LapCompensate(unsigned long time){
+  return lapLapTimeRatio * time;
 }
 
 bool CheckLapStart(){
   bool isOn = digitalRead(detectorPin);
-  bool bouncePrevention = timeElapsed > 1000;
+  bool bouncePrevention = ( currentFrameTime > minPossibleLapTime ) || startMode;
   if( isOn != wasOn && bouncePrevention ){
     wasOn = isOn;
     if( isOn ){

#define detectorPin 2
#define resetPin 1

unsigned long baseLapTime = 86200;
unsigned long c1 = 30+250;
unsigned long c2 = 5760+250;
unsigned long c3 = 14120;
unsigned long c4 = 32280;
unsigned long c5 = 47440;
unsigned long c6 = 59440;
unsigned long c7 = 77200+1000;

byte m1 = PWM_REV6;
byte m2 = PWM_BRK;
byte m3 = PWM_FWD6;
byte m4 = PWM_REV6;
byte m5 = PWM_BRK;
byte m6 = PWM_FWD6;
byte m7 = PWM_BRK;


elapsedMillis timeElapsed; 
unsigned long currentFrameTime;
unsigned long lastLapTime;
unsigned long lastFrameTime;

byte TURN = BLUE;



void setup(){
  pinMode(detectorPin, INPUT );
  lastLapTime = defaultLapTime;

}

bool HasCrossedTime(unsigned long time){
  time = LapCompensate(time);
  return ( lastFrameTime < time ) && ( time <= currentFrameTime );
}

