     if(currentTick[4]>=currentPeriod[4]){
       if(currentPosition[4]>=MAX_POSITION){
         sbi(portd,5);
+        sbi(portddirection,5);
       }else if(currentPosition[4]<=MIN_POSITION){
         cbi(portd,5);
+        cbi(portddirection,5);
       }
 
       if(ebi(portd,5)){

    if(currentTick[6]>=currentPeriod[6]){
      if(currentPosition[6]>=MAX_POSITION){
        sbi(portd,7);
      }else if(currentPosition[6]<=MIN_POSITION){
        cbi(portd,7);
      }

      if(ebi(portd,7)){


      if(ebi(portc,0)){
        cbi(portc,0);
      }else{
        sbi(portc,0);
      }
      currentTick[14]=0;
    }
