1

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() {

  bStepper.setMaxSpeed(200);  
  bStepper.setAcceleration(30);
}

 void loop() {

   aStepper.setSpeed(20);
   aStepper.step(1016);

   bStepper.moveTo(-6000);   
   bStepper.runToPosition(); 

   aStepper.setSpeed(20);
   aStepper.step(-1016);
}

Thank you in advance

A'dam
  • 11
  • 1

0 Answers0