Stepper motor does not turn anticlockwise

Hi, I am using nema 17 and TB6560 driver. I am trying to run the motor in clockwise and anti-clockwise direction. but the motor just keeps running in clockwise direction even when the stepsize given is negative. please help.
this is the code

AccelStepper stepper1(AccelStepper::DRIVER, STEPPER1_STEP_PIN, STEPPER1_DIR_PIN);

int stepsize1;
void setup()

void loop()
  if (stepper1.distanceToGo() == 0)

    stepsize1 = 200; // or -200

You should take a look at the documentation of AccelStepper :wink:
using moveTo / setMaxSpeed together with setSpeed/runSpeed does not make sense.
if you want to position the stepper with moveTo use only setMaxSpeed and run instead of runSpeed.

Thank you so much that brought a lot of clarity.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.