#include <AccelStepper.h>
#include <MultiStepper.h>
#define blue 8
#define pink 9
#define yellow 10
#define orange 11
AccelStepper stepper(AccelStepper::HALF4WIRE, orange, pink, yellow, blue);
int target = 2048;
int current_pos = 0;
int steps_left;
void setup()
{
Serial.begin(9600);
stepper.setMaxSpeed(1200);
stepper.setSpeed(200);
stepper.setAcceleration(110);
}
void loop()
{
target = stepper.targetPosition();
current_pos = stepper.currentPosition();
steps_left = stepper.distanceToGo();
steps_left = target - current_pos;
if(steps_left != 0)
{
//the code here is supposed to be run to 200 steps without blocking and
after it done, update the current position till it reach 2048 steps
stepper.runToNewPosition(200);
delay(1000);
}
}