Accelstepper motor problems

Hello there, for a project where I have to make 'stranbeesten' with arduino I decided to use 2 stepmotors to run them synchronously, I used Accelstepper and Multistepper for this.
The 2 stepmotors are feeded by 2 seperate L298N H-bridges.
When I ran the program both motors ran in the same direction forward of eachother and after that in the opposite direction backward, after which it loops but instead of moving in the same direction forward again they went opposite forward and then opposite backward and repeat.

I don't know what I'm doing wrong.
My goal is to drive the motors with bluetooth to make them both go forward, backward, left and right
(So opposite forward, opposite backward, same forward and same backward)

As you can see this is literally the example of the accelstepper/multistepper (both libraries are in use)

#include <AccelStepper.h>
#include <MultiStepper.h>
// EG X-Y position bed driven by 2 steppers
// Alas its not possible to build an array of these with different pins for each :-(
AccelStepper stepper1(AccelStepper::FULL4WIRE, 4, 5, 6, 7);
AccelStepper stepper2(AccelStepper::FULL4WIRE, 8, 9, 10, 11);
// Up to 10 steppers can be handled as a group by MultiStepper
MultiStepper steppers;
void setup() {
  Serial.begin(9600);
  // Configure each stepper
  stepper1.setMaxSpeed(100);
  stepper2.setMaxSpeed(100);
  // Then give them to MultiStepper to manage
  steppers.addStepper(stepper1);
  steppers.addStepper(stepper2);
}
void loop() {
  long positions[2]; // Array of desired stepper positions
  
  positions[0] = 100;
  positions[1] = 50;
  steppers.moveTo(positions);
  steppers.runSpeedToPosition(); // Blocks until all are in position
  delay(1000);
  
  // Move to a different coordinate
  positions[0] = -100;
  positions[1] = 100;
  steppers.moveTo(positions);
  steppers.runSpeedToPosition(); // Blocks until all are in position
  delay(1000);
}

Strandbeest.ino (1.04 KB)

wenbornwilliam:
When I ran the program both motors ran in the same direction forward of eachother and after that in the opposite direction backward, after which it loops but instead of moving in the same direction forward again they went opposite forward and then opposite backward and repeat.

That is not very clear - maybe you can explain it with numbers?

It seems to me your program makes the motors do the following moves (I may have clockwise and counter-clockwise mixed up)

0 to 100 (CW) 0 to 50 (CW)

100 to -100 (CCW) 50 to 100 (CW)

-100 to 100 (CW) 100 to 50 (CCW)

100 to -100 (counter clockwise) 50 to 100 (CW)

-100 to 100 (CW) 100 to 50 (CCW)

...R