Wiring and Coding for Two Stepper Motors with Arduino UNO

Hello, I have these two stepper motors.
For Motor Description: Click Here

And two EasyDrivers from SparkFun: Click Here

And Arduino UNO. I need to run two motors with different speed. I used this site for help to wire the items to run those motors few days back. I used BreadBoard to connect all the items.

Unfortunately, now my motors can't run. When I connect and upload the program to Arduino, motor run only one pulse in one direction and then next pulse in opposite direction. Was it problem with loose connection or something like that? I used the following color code for my motor with Easydriver. In EasyDriver it is not marked which one is A and which one is A-. So I assumed first A is A and 2nd one is A-. I have used coding from EasyDriver example page.

A: Blue
A-: Red
B: Green
B-: Black

To try, I also switched both pairs of wire to get continuous run. But I failed.

Could you please anyone suggest me the possible reason? Considering the specifications of my motors and driver, is there any mismatch??? Do you feel I should change driver option? Then, which one best suits for my case considering currents/voltage? Thank you very much.

As you did not post your code I can't comment on it.

I suggest you start with the very simple code in this Demo

That code was designed for a stepper driver that is set for single steps. I think the Easydriver may default to microsteps so you might need to increase the number of steps in the demo code.

And post a diagram of how you have everything wired up - including your power sources. A photo of a pencil sketch will be fine.

...R

You need to check all your wiring and connections.

Note that you must never connect/disconnect the motor windings from the motor driver
when it is powered up - that typically destroys the driver from inductive kickback - power
down everytime you want to replug.

@MarkT: Thank you very much for your information.

@Robin2: Thank you very much. I used this simple code just to check for single motor.

void setup() {                
  pinMode(8, OUTPUT);     
  pinMode(9, OUTPUT);
  digitalWrite(8, LOW);
  digitalWrite(9, LOW);
}

void loop() {
  digitalWrite(9, HIGH);
  delay(1);          
  digitalWrite(9, LOW); 
  delay(1);          
}

To run both motors:

#include <AccelStepper.h>

// Define two steppers and the pins they will use
AccelStepper stepper1(1, 9, 8);
AccelStepper stepper2(1, 7, 6);

int pos1 = 3600;
int pos2 = 5678;

void setup()
{  
  stepper1.setMaxSpeed(3000);
  stepper1.setAcceleration(1000);
  stepper2.setMaxSpeed(2000);
  stepper2.setAcceleration(800);
}

void loop()
{
  if (stepper1.distanceToGo() == 0)
  {
        pos1 = -pos1;
    stepper1.moveTo(pos1);
  }
  if (stepper2.distanceToGo() == 0)
  {
    pos2 = -pos2;
    stepper2.moveTo(pos2);
  }
  stepper1.run();
  stepper2.run();
}

And I have attached two photos for single and dual motor wiring. Please comment on it now.
IS THE COLOR CODE I USED RIGHT??? Because, I found two different color coding for motor wires. SO confused.

Considering rigid connection and stability, do you think I should shift to other drivers / setup like, Adafruit Motor Shield v 2 (completely stackable using headers)?

Waiting for your comment. Thank you very much for your support.

khondoke:
And I have attached two photos for single and dual motor wiring. Please comment on it now.
IS THE COLOR CODE I USED RIGHT??? Because, I found two different color coding for motor wires. SO confused.

In your diagram the wiring seems to be the same for both motors. Does they work?

I presume you got each motor working separately with my code.

Did you get one motor working with the Accelstepper code?

Just be very careful not to cause or allow even a momentary disconnection between the motor and the driver while the driver is powered up.

Personally I have no shields. I don't see that they add any value - but that is very much a personal thing.

...R

Hello Robin2,

I tested both EasyDrivers. They are out of order, I think. I followed the way mentioned here to test whether driver is damaged or not.

After using a new driver, I got my motor running :smiley: !!!

Thank you very much for your support. Hope, I will not have any problem, if have surely I will post for help :cold_sweat:

Have a nice day.

i have 2 motor how to connect in arduino ??
plz give me code for it run forward&back also right&left using 2 axis tumb joystickcap

vaisagh:
i have 2 motor how to connect in arduino ??
plz give me code for it run forward&back also right&left using 2 axis tumb joystickcap

Read the Thread stepper motor basics. It also has a link to test code.

...R