I'm currently expanding on a previous student's project using a 2560 board to control 5 stepper motors. I got everything connected and the sketch that he used uploaded but for some reason the motors are not moving at all. I'm very new to Arduino so if I'm missing anything please let me know! Any help is appreciated.
The sketch that I uploaded:
#include <AccelStepper.h>
// Create an AccelStepper instance
AccelStepper stepper1(1,23,22); //type of stepper motor, arduino pin # for step, arduino pin # for direction
AccelStepper stepper2(1,25,24);
AccelStepper stepper3(1,27,26);
AccelStepper stepper4(1,29,28);
AccelStepper stepper5(1,31,30);
float maxspeed = 1; // sets max speed, in steps per second
int maxacceleration = 12000; // high acceleration allows for "instant" change in speed
long direction = 1; // keep magnitude 1 | positive = infuse | negative = withdrawal
long maxsteps = 37000; // target number of steps to run for
void setup() {
stepper1.setMaxSpeed(maxspeed); // Adjust the upper limit of speed
stepper1.setAcceleration(maxacceleration); // Adjust the acceleration
stepper1.moveTo(direction*maxsteps); // Set the absolute target position. This is the desired position.
stepper2.setMaxSpeed(maxspeed);
stepper2.setAcceleration(maxacceleration);
stepper2.moveTo(direction*maxsteps);
stepper3.setMaxSpeed(maxspeed);
stepper3.setAcceleration(maxacceleration);
stepper3.moveTo(direction*maxsteps);
stepper4.setMaxSpeed(maxspeed);
stepper4.setAcceleration(maxacceleration);
stepper4.moveTo(direction*maxsteps);
stepper5.setMaxSpeed(maxspeed);
stepper5.setAcceleration(maxacceleration);
stepper5.moveTo(direction*maxsteps);
}
void loop() {
stepper1.run(); // Tries to get stepper to target position. Goes one step per call
stepper2.run();
stepper3.run();
stepper4.run();
stepper5.run();
}