I am quite new to this , I am trying to program two motors , aStepper and bStepper. I want the program to rotate aStepper then rotate the bStepper and when that is done rotate aStepper again , and then repeat. The first iteration works fine.However, it only does the loop once and the bStepper doesn't rotate again.

Am I doing something wrong with the loop?

(aStepper is the UNIPOLAR 28BYJ-48 connected to its driver , and bStepper is a Nema 17 connected to A4988)

#include <AccelStepper.h>  
#include <Stepper.h>

#define StepsPerRotation 2038 

#define dirPin 2      
#define stepPin 3
#define motorInterfaceType 1

AccelStepper bStepper = AccelStepper(motorInterfaceType, stepPin, dirPin); 
Stepper aStepper(StepsPerRotation, 8, 10, 9, 11);

void setup() {


 void loop() {




Thank you in advance

  • How should bStepper move again after the first time? You directed it to go to position -6000, so it will go to -6000 on the first run. On the second it already is there, so further movement
    – chrisl
    Nov 22, 2019 at 13:50
  • Oh , I thought after it completes the loop it would just run again. How can i better approach this? with bstepper.runSpeed(); instead?
    – A'dam
    Nov 22, 2019 at 13:54


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.