#include <Stepper.h>
// Define the number of steps per revolution for your motor
const int stepsPerRevolution = 200;
// Initialize the stepper library on pins 8 through 11
Stepper myStepperX(stepsPerRevolution, 8, 9, 10, 11);
Stepper myStepperY(stepsPerRevolution, 4, 5, 6, 7);
void setup() {
// Set the speed at 60 rpm:
myStepperX.setSpeed(60);
myStepperY.setSpeed(60);
// Initialize the serial port:
Serial.begin(9600);
}
void loop() {
// Step forward 100 steps:
Serial.println("Moving X axis forward");
myStepperX.step(100);
delay(500);
// Step backward 100 steps:
Serial.println("Moving X axis backward");
myStepperX.step(-100);
delay(500);
// Step forward 100 steps:
Serial.println("Moving Y axis forward");
myStepperY.step(100);
delay(500);
// Step backward 100 steps:
Serial.println("Moving Y axis backward");
myStepperY.step(-100);
delay(500);
}