2 stepper motors with independent actions

I’m very new at all this and I’m trying to get one of my motors (12v) to spin continuously and the other one move half way back and forth

I’m using a UNO R3, have 2 A4988 drivers, and the 2 12v motors.

I also want to make it so I only have 1 power input rather than powering the Arduino with a usb AND the motors with a separate 12v power supply

My current setup is (as best as possible)
Motor 1:
Step/Dir in port 2/3 of the arduino
Motor 2:
Step/Dir in port 4/5

The VIN & GND of the arduino are wired to the first slot of the top rail of my breadboard.
Next to that is a 100uF capacitor
Then I have 2 pairs of positives and negatives going to each VMOT and GND of the drivers.

The 5v & GRN of the Arduino are wired to the bottom rail of the bread board and then I have a pair of POS and NEG going to VDD & GND of the driver

My motors seem to be stuttering with the code I have BUT I also don’t know if I did my code correctly.

What is the best way to wire up TWO 12V motors to come from a SINGLE power source (arduino port or external power supply) AND what is the best code for it??

I’m a very visual learner and don’t know a lot of technical terms, I know the stuff I can see on my drivers and arduino lol

CODE:

#include <AccelStepper.h>
#include <MultiStepper.h>

// Define some steppers and the pins the will use
AccelStepper stepper1(2, 3); // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5
AccelStepper stepper2(4, 5);

MultiStepper steppersControl; 

long gotoposition[3];


void setup()
{  
    stepper1.setMaxSpeed(1000);
    stepper2.setMaxSpeed(1000);

    steppersControl.addStepper(stepper1);
    steppersControl.addStepper(stepper2);
    }
void loop() {

    gotoposition[0] = 1000;
    gotoposition[1] = 1000;

    steppersControl.moveTo(gotoposition);
    steppersControl.runSpeedToPosition();

    delay(1000);

    gotoposition[0] = 0;
    gotoposition[1] = 0;

    steppersControl.moveTo(gotoposition);
    steppersControl.runSpeedToPosition();
    
    delay(1000);

Read the pinned post re 'How to get the most from the forum'

The motors have to be powered by a separate power source from the UNO. But ALL grounds must be tied together.
Using a run-of-the-mill breadboard is asking for trouble, and even one of the very few good ones can be a problem. Also, the quality of your wires will be a factor. If the pins are slightly undersized, as the cheap ones are, they will make poor contact.
Once you provide us with what is needed, we may be able to get more specific, but I can tell you noise suppression may be an issue.
This material requires a LOT of reading.

You can spend weeks spinning your wheels, or you might get lucky and solve your problem quickly. To avoid unnecessary delays, it’s crucial to provide an annotated schematic of your circuit as you have it wired, showing all connections, including power, ground, and power supplies. I recommend it be in English, you can translate before posting if needed.

Why Detailed Information Matters:

Annotated Schematics: These are essential because they show exactly how your circuit is set up. Without them, it's difficult for anyone to understand what you’ve done, which makes troubleshooting nearly impossible. Fritzing diagrams or unclear pictures are not enough. A good schematic can save days in time when problems occur.

Technical Information: Many modules look similar and may even have the same name, but they can function differently. This is why we always ask for links to detailed technical information, not just sales pages like those on Amazon, which often lack the specifics we need.

Post your Software Without that we do not have a clue as to how it is expected to operate. Be sure to use code tags.

Show All Connections: It’s important to include every connection, especially power, ground and power sources in your schematic. Missing these details makes it hard to determine if a setup issue might be causing your problem.

My Process:

When I see a question, I spend a moment assessing it. If it’s missing critical information, I might ask for it. However, if it's repeatedly lacking important details, I may assume the questioner is not serious and move on to another query.

What You Need to Consider:

We don’t know your skill level or what resources you have available. If you’re missing key technical details or seem unprepared, it may indicate that you need to spend more time learning the basics before starting your project.

Providing the right information upfront will help you get the best possible assistance and avoid the frustration of running into dead ends. Let us help you by sharing what you have clearly and completely!

A stuttering stepping motor is often caused by asking it to go too fast. Try slowing down the speed you are asking it to go at.

But we can't comment on code we can not see, so please post this code.

You might want to look at this How to get the best out of this forum before you proceed any further. It tells you how to post code on this forum.

Draw a picture of your wiring.

I updated it sorry!

I updated it

updated!

updated with code and diagram

Stop right there.
The A4988 is a current comtrolling stepper driver.
If your motors are truly 12volt,
then the A4988 supply needs to be at least 24volt or higher.
Please post the model or a link to the motor, so we can check.
Leo..

[edited] What are the blue blocks? (MOTORS) What are the red blocks? (DRIVERS) What are the white blocks? (HEAT SINK) Where are the connections from the driver to the motors? (12VDC) Where is motor power? (FROM DRIVER) Where is logic power? So many words, yet nothing visual.

Hi, @sarmbrust12
Welcome to the forum.

Please don't update old posts, always add information in new posts.

Can you please post a copy of your circuit, a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.

Thanks.. Tom.... :smiley: :+1: :coffee: :australia:

The motor you linked is indeed a low impedance stepper and suitable for the A4988 driver. It's not really a 12V motor - 12V maybe a suggestion for driver voltage.

The code you provided isn't complete - at least the closing brace at the end is missing.

If you want the motors to do independent actions you must not use multistepper. And even worse multistepper does not support acceleration.

But the main mistake in your code is this:

The default mode is completely wrong for your driver.
Try with

AccelStepper stepper1(AccelStepper::DRIVER, 2, 3); 
AccelStepper stepper2(AccelStepper::DRIVER, 4, 5);

Did you set the coil current correctly at the A4988? This is mandatory!

And pay attention to all the hardware and forum related tips from the other helpers.

As @MicroBahner said, 12volt is suitable for that setup.
The 12volt rating points to the (minimum) voltage needed for the A4988 driver.
The driver converts it to the voltage/current for the motor, which is actually 3.6volt/1A per coil.
Leo..

@sarmbrust12

Your other topic on the same subject has been closed

Please do not duplicate your questions as doing so wastes the time and effort of the volunteers trying to help you as they are then answering the same thing in different places.

Please create one topic only for your question and choose the forum category carefully. If you have multiple questions about the same project then please ask your questions in the one topic as the answers to one question provide useful context for the others, and also you won’t have to keep explaining your project repeatedly.

Repeated duplicate posting could result in a temporary or permanent ban from the forum.

Could you take a few moments to Learn How To Use The Forum

It will help you get the best out of the forum in the future.

Thank you.