     if(currentTick[2]>=currentPeriod[2]){
       if(currentPosition[2]>=MAX_POSITION){
         sbi(portd,3);
+        sbi(portddirection,3);
       }else if(currentPosition[2]<=MIN_POSITION){
         cbi(portd,3);
+        cbi(portddirection,3);
       }
 
       //Update currentPosition


      if(ebi(portd,4)){
        cbi(portd,4);
        cbi(portddirection,4);
      }else{
        sbi(portd,4);
        sbi(portddirection,4);
      }
      currentTick[4]=0;
    }


      if(ebi(portb,2)){
        cbi(portb,2);
      }else{
        sbi(portb,2);
      }
      currentTick[10]=0;
    }
