#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, 2, 3, 4, 5);
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(1000);
//stepper2.setMaxSpeed(1000);
// Then give them to MultiStepper to manage
steppers.addStepper(stepper1);
steppers.addStepper(stepper2);
}
void loop() {
long positions[2]; // Array of desired stepper positions
stepper1.setMaxSpeed(1000);
stepper2.setMaxSpeed(1000);
stepper1.setAcceleration(1);
positions[0] = 1000;
positions[1] = 200;
steppers.moveTo(positions);
steppers.runSpeedToPosition(); // Blocks until all are in position
delay(1000);
// Move to a different coordinate
positions[0] = 0;
positions[1] = 0;
steppers.moveTo(positions);
steppers.runSpeedToPosition(); // Blocks until all are in position
delay(1000);
}