multiple action

I want to make a stepper run a full circle while a servo moves and a dc motor spins if I press a button. however, I can only get it where the stepper first makes a full circle and then the servo starts moving. how do I make it where de servo and the stepper both start when I press the button
buttonState = digitalRead(buttonPin);

if (buttonState == HIGH) {

myStepper->step(513, FORWARD, SINGLE);
myStepper->release();

delay(300);
myservo.write(0);
delay(1000);

myMotor->run(FORWARD);
myMotor->setSpeed(75);

delay(3000);
myMotor->setSpeed(0);

delay(1000);
myservo.write(55);
}

Temp_potMeter.ino (1.76 KB)

Taking all those delays out would be a good start.

Steve

You will have to break the motion into smaller steps.

You want the stepper to rotate 513 steps and the servo to turn 55 degrees.

  if (buttonState == HIGH)
  {
    // Start the motor
    myMotor->setSpeed(75);
    myMotor->run(FORWARD);

    // Turn the stepper and servo
    for (int step = 0; step < 513; step++)
    {
      myStepper->step(1, FORWARD, SINGLE);
      myservo.write((55 * i) / 512);
    }
    
    // Stop the motor
    myMotor->setSpeed(0);

    // Release the stepper
    myStepper->release();
  }