#include <AccelStepper.h>
#define SM1_DIR 2
#define SM1_STEP 1
#define SM2_DIR 4
#define SM2_STEP 3
AccelStepper stepper1(1, SM1_STEP, SM1_DIR);
AccelStepper stepper2(1, SM2_STEP, SM2_DIR);
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, Raspberry Pi Pico!");
// Change these to suit your stepper if you want
stepper1.setMaxSpeed(200.0);
stepper1.setAcceleration(100.0);
stepper1.moveTo(24);
stepper2.setMaxSpeed(300.0);
stepper2.setAcceleration(100.0);
stepper2.moveTo(1000000);
}
void loop() {
// put your main code here, to run repeatedly:
// If at the end of travel go to the other end
if (stepper1.distanceToGo() == 0)
stepper1.moveTo(-stepper1.currentPosition());
stepper1.run();
stepper2.run();
}