I just bought a Adafruit motor shield and I am trying to develop code that will run two stepper motors at the same time. I looked at the tutorial but I kinda don't fully understand it. If i used the following example code from the site below what would I have to add to drive two motors at the same time.
void doublestep (int steps, int direction, int style) {
while (steps--) {
motor1.step(1, direction, style);
motor2.step(1, direction, style);
}
}
How can I implement this example function for driving two motors in their example code below
Code: Select all
#include <AFMotor.h>
AF_Stepper motor(48, 2);
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Stepper test!");
motor.setSpeed(10); // 10 rpm
motor.step(100, FORWARD, SINGLE);
motor.release();
delay(1000);
}
void loop() {
motor.step(100, FORWARD, SINGLE);
motor.step(100, BACKWARD, SINGLE);
motor.step(100, FORWARD, DOUBLE);
motor.step(100, BACKWARD, DOUBLE);
motor.step(100, FORWARD, INTERLEAVE);
motor.step(100, BACKWARD, INTERLEAVE);
motor.step(100, FORWARD, MICROSTEP);
motor.step(100, BACKWARD, MICROSTEP);
}