Arduino 2560 board uploaded sketch but nothing is happening

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();

}

There are a number of possible wiring mistakes.
Please post schematics. Pen and paper might work, showing one of the steppers, the driver and power supply.

For future succesful posting please read, and use, How to get the best out of this forum - Using Arduino / Project Guidance - Arduino Forum

Did that previous project work? If so, do you have a copy of the working code and information about how it was wired?
If the answers are yes, then it might be worth starting from the working project and confirm it works as expected. Then add things in an orderly manner. After adding something check it hasn't stopped working.
FWIW I added some Serial.println()s to your code, built it for Mega 2560 and ran it. It definitely runs the loop regularly, i.e. it's no hanging up in the code. That's with no stepper motors connected

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.