Skip to content

Multiple stepper motor delay #38

@vikaskandari

Description

@vikaskandari

Hello, when using multiple stepper motors they don't work at the same time they work one by one, due to while loop used in the code.

#include <Stepper.h>

const int spr = 200;  // change this to fit the number of steps per revolution
const int rmp = 100;
// for your motor

// initialize the stepper library on pins 8 through 11:
Stepper sm1(spr, 52, 50, 48, 46);
Stepper sm2(spr, 44, 42, 40, 38);
Stepper sm3(spr, 36, 34, 32, 30);
Stepper sm4(spr, 28, 26, 24, 22);




void setup() {
  // set the speed at 60 rpm:
  sm1.setSpeed(rmp);
  sm2.setSpeed(rmp);
  sm3.setSpeed(rmp);
  sm4.setSpeed(rmp);
  Serial.begin(9600);

  //  myStepper.step(stepsPerRevolution);
}

void loop() {
  // step one revolution  in one direction:
  Serial.println("clockwise");
  sm1.step(spr);
  sm2.step(spr);
  sm3.step(spr);
  sm4.step(spr);

}

when m1 finished its first loop then m2 starts and it goes on.

Please change the while loop with some async loop which will allow other stepper motors to start simultaneously.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions