please help me. how to use 2 stepper motors, the motor 1 forward and then the motor 2 forward and then stop.
this is the code that im using.
#include <AccelStepper.h>
AccelStepper stepper1(AccelStepper::DRIVER, 2, 5);
AccelStepper stepper2(AccelStepper::DRIVER, 4, 7);
void setup()
{
Serial.begin(9600);
stepper1.setMaxSpeed(3000);
stepper1.setAcceleration(1000);
stepper2.setMaxSpeed(3000);
stepper2.setAcceleration(1000);
}
void loop()
{
if (Serial.available() > 0) {
char a = Serial.read();
switch(a)
{
case '0':{
stepper1.moveTo(2000);
break;
}
case '1':{
stepper2.moveTo(1000);
break;
}
default : {
// default is optional
}
}
{
stepper1.run();
stepper2.run();
}
}
}
but this code don't work, there may be something wrong
thank you