Как уйти от паразитного delay??

exez
exez аватар
Offline
Зарегистрирован: 04.04.2015

Подскажите плиз. Имеем два шаговых мотора. Один вращается с постоянной скоростью, а второй надо вращать с ускорением. Вопрос. Как уйти от паразитного dealy?

 

void EQUp()
{
    indi++; if (indi<30) {digitalWrite(13,LOW);} if (indi>1){digitalWrite(13,HIGH);} if (indi>2){digitalWrite(13, LOW); indi=0;}

Serial.print("spd :   "); Serial.println(spd);
Serial.print("spd1:   "); Serial.println(spd1);

    digitalWrite(motor11, HIGH);
    digitalWrite(motor14, LOW);  delay(spd); delayMicroseconds(spd1);  // 1000

      button11st = digitalRead(11);
      button12st = digitalRead(12);  
    
      if (button11st==LOW)
      {return;}
      else

      if (button12st==LOW)
      {return;}
      else
      
    digitalWrite(motor12, HIGH); delay(spd); delayMicroseconds(spd1); 

      button11st = digitalRead(11);
      button12st = digitalRead(12);  
    
      if (button11st==LOW)
      {return;}
      else

      if (button12st==LOW)
      {return;}
      else
 
    digitalWrite(motor11, LOW);  delay(spd); delayMicroseconds(spd1);

      button11st = digitalRead(11);
      button12st = digitalRead(12);  
    
      if (button11st==LOW)
      {return;}
      else

      if (button12st==LOW)
      {return;}
      else
 
    digitalWrite(motor13, HIGH); delay(spd); delayMicroseconds(spd1); 
 
      button11st = digitalRead(11);
      button12st = digitalRead(12);  
    
      if (button11st==LOW)
      {return;}
      else

      if (button12st==LOW)
      {return;}
      else
 
    digitalWrite(motor12, LOW);  delay(spd); delayMicroseconds(spd1);
 
      button11st = digitalRead(11);
      button12st = digitalRead(12);  
    
      if (button11st==LOW)
      {return;}
      else

      if (button12st==LOW)
      {return;}
      else
 
    digitalWrite(motor14, HIGH); delay(spd); delayMicroseconds(spd1);
 
      button11st = digitalRead(11);
      button12st = digitalRead(12);  
    
      if (button11st==LOW)
      {return;}
      else

      if (button12st==LOW)
      {return;}
      else
 
    digitalWrite(motor13, LOW);  delay(spd); delayMicroseconds(spd1);
 
      button11st = digitalRead(11);
      button12st = digitalRead(12);  
    
      if (button11st==LOW)
      {return;}
      else

      if (button12st==LOW)
      {return;}
      else
 
    digitalWrite(motor11, HIGH); delay(spd); delayMicroseconds(spd1);

      button11st = digitalRead(11);
      button12st = digitalRead(12);  
    
      if (button11st==LOW)
      {return;}
      else

      if (button12st==LOW)
      {return;}
      else
 
//    digitalWrite(motor21,LOW);
//    digitalWrite(motor22,LOW);
//    digitalWrite(motor23,LOW);
//    digitalWrite(motor24,LOW); 
    
    digitalWrite(motor31,LOW);
    digitalWrite(motor32,LOW);
    digitalWrite(motor33,LOW);
    digitalWrite(motor34,LOW);     

}

 

maksim
Offline
Зарегистрирован: 12.02.2012

AccelStepper