My aim is to have two steppers, one for the x - axis and one for the y - axis. Will this code work, or am i missing somthing?
#include <Stepper.h>
const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
// for your motor
// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 4,5,6,7,8,9,10,11);
void setup() {
// initialize the serial port:
Serial.begin(9600);
const unsigned long int X_STEPS_MAX = 745683;
const unsigned long int Y_STEPS_MAX = 87346;
unsigned long int X_position = 0;
unsigned long int Y_position = 0;
boolean X_increasing = true;
void loop() {
if (X_increasing) {
if (X_position == X_STEPS_MAX) {
Y_position ++;
Y_step_down();
X_increasing = false;
} else {
X_position++;
X_step_right();
}
} else { // decreasing
if (X_position == 0) {
Y_position ++;
Y_step_down();
X_increasing = true;
} else {
X_position--;
X_step_left();
}
}
while (Y_position == Y_STEPS_MAX); // stop everything
}