I'm using two Nema 17 Motors (bipolar) each on a separate MP6500 driver to rotate a platform in azimuth and broadside. This results in a DIR pin and a STEP pin for each of the stepper motors (4 pins total). I have configured my code as below. I can use this code successfully to drive only one stepper motor at a time (if I block out the other stepper code). I cannot figure out why the program won't work if I have both steppers in the code. I don't need to drive both at the same time, I just want to run both using one program. It's a pain to go back and forth. Why can't I run both of the stepper motors using this one program?
#include <Stepper.h>
Stepper azimuth(200, 3, 5);
//Stepper broadside(200, 9, 10);
void setup() {
// Setup the pins as Outputs
azimuth.setSpeed(100);
//broadside.setSpeed(60);
Serial.begin(9600);
Serial.println("setup");
}
void loop() {
while (!Serial.available()) {}
char val = Serial.read();
while (val == 'a') {
azimuth.step(400);
Serial.println(val);
val = "";
delay(300);
}
while (val == 'q') {
azimuth.step(2);
Serial.println(val);
val = "";
delay(300);
}
while (val == 'w') {
//broadside.step(200);
Serial.println(val);
val = "";
delay(300);
}
while (val == 'e') {
//broadside.step(2);
Serial.println(val);
val = "";
delay(300);
}
}