This is the code that I am using to run my stepper motors:
#include <Stepper.h>
const int stepsPerRev = 513; // steps per rev
const int speedRpm = 5; // speed rpm
Stepper stepper1(stepsPerRev, 10, 8, 9, 11);
Stepper stepper2(stepsPerRev, 6, 4, 5, 7);
void setup() {
// set speed
stepper1.setSpeed(speedRpm);
stepper2.setSpeed(speedRpm);
}
void loop() {
// step one revolution in one direction:
stepper1.step(stepsPerRev);
stepper1.step(-stepsPerRev);
stepper2.step(stepsPerRev);
stepper2.step(-stepsPerRev);
delay(100);
}
But when I run it one motor runs and then stops and then the other one goes and then stops and they only run one at a time. I know that this is because arduino runs its code line by line, but i need help making them run at the same time. Anything will help!
Thanks!