Issues integrating a stepper motor with a Arduino Uno

Hello everyone,

I am attempting to drive two stepper motors with an arduino uno and am facing some difficulties. The code is uploaded to the board and won't run.

I want the two motors to run simultaneously at the same rate ending and starting at the same time.

Do you see where I might have gone wrong with my code?

'''
#include "AccelStepper.h"

AccelStepper left(AccelStepper::FULL2WIRE, 12, 9);

AccelStepper right(AccelStepper::FULL2WIRE, 7, 4);

long check_time;

void setup() {

left.setMaxSpeed(400);
right.setMaxSpeed(400);
}

void loop() {
left.setSpeed(200);
right.setSpeed(200);
check_time = millis() + 5000;
while(millis() < check_time) {
left.runSpeed();
right.runSpeed();
}
delay(2000);

left.setSpeed(-200);
right.setSpeed(-200);
check_time = millis() + 5000;
while(millis() < check_time) {
left.runSpeed();
right.runSpeed();
}
delay(2000);

}
'''
Thanks,
FunkyCatDealer

how do you know?

I plugged in the Arduino to my computer and selected the board and port. Then I verified there were no issues with my code before clicking the arrow to upload the code.

this code also did not work:

#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, 8, 9, 10, 11);

void setup() {
// set the speed at 60 rpm:
myStepper.setSpeed(60);
// initialize the serial port:
Serial.begin(9600);
}

void loop() {
// step one revolution in one direction:
Serial.println("clockwise");
myStepper.step(stepsPerRevolution);
delay(500);

// step one revolution in the other direction:
Serial.println("counterclockwise");
myStepper.step(-stepsPerRevolution);
delay(500);
}

What stepper motors?
What stepper driver boards?
How are the components connected and powered?

Can you provide us with the component information and a hand drawn schematic?

The stepper motor and driver are together in one unit:
Stepper motor and driver link https://www.automationdirect.com/adc/shopping/catalog/motion_control/stepper_systems/integrated_stepper_motors_-z-_drives/stp-mtrd-17038

The arduino is plugged via USB into my laptop and the 2 stepper motors are powered using a 12V 1.3A DC battery per motor

battery link: https://www.amazon.com/Mighty-Max-Battery-ML1-3-12-BATTERY/dp/B00K8V2DFQ?th=1

I don't have a hand drawn schematic because this is my first time doing this, sorry :frowning:

Do you have ALL the - connections on the 10 pin connector connected to your Arduino ground?

my EN+, EN-, out+, out-, and NC pins are not connected connected to anything. My V+ and V- are connected the the DC battery and my Step+, Step-, Dir+, Dir- are connected to the arduino open spots. is this good?

Consider looking at the documentation to see what happens when there is NO connection to the enable EN pins.

The documentation claims that only the Step and Dir wires are required, EN and out are optional

Please use code tags; I can see that you tried but replace the three ticks ''' in the beginning and the end by three backticks ```.

```
your code here
```

Your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advice on) your project :wink: See About the IDE 1.x category.

You can create one :wink:

So the question is what the motors actually do? Don't run at all, don't run at the same time?

I am unsure of how to draw one, is there som source that outlines the process?

The motors do not move at all currently. :frowning:

The Quick Start Guide shows this

Step 8:
Optionally, you can test motor operation by activating
switch 4 in the “SETUP” DIP switch bank to initiate a self
test. The self test continually rotates the motor forward
and backward 2 1/2 revolutions.

Does the stepper run with this self test?

I am concerned about your use of a small battery for the project. Have you monitored the battery voltage while trying to run the motors? Do you have a battery charger to keep the battery fully charged? Perhaps charge the battery WHILE running the motor tests.

Hi newbie @funkycatdealer welcome to world top arduino forum

Before getting started it is strongly recommended to Visit this for better use