Stepper Motors Restart after 1 iteration in loop


I am using an Arduino Mega ADK with six stepper motors and drivers. Motor and driver can be found here.

I have set the wiring up for 6 stepper motors, which can be seen in the diagram that I have drawn and attached to this post.

When I run a simple program form the example code in Arduino for stepper motors, the program works fine. When I modify the program, just copy pasting and renaming, to allow for six stepper motors to be tested by the program. The program runs once, then it stops, all the lights on all of the driver boards shut off then after a few seconds it starts at the top of the loop again. Last week the program was working perfectly, I was inputting ~12 volts into the breadboard. This week, I started having the problem that I mentioned before, I have tried to change the input voltage all the way to the max that the Arduino board can handle ~20 volts. Additionally, I have redone all the wiring and the problem still persists, any ideas on what might be going wrong?


Connect the Arduino directly to the power supply, not through the breadboard.

Connect the Arduino directly to the power supply, not through the breadboard.

And what WattsThat is suggesting is, breadboards are notorious for connections not suitable for high current situations, like driving Stepper Motors. A poor connection [i.e. a connection with a lot of, for instance, contact resistance], can drop enough voltage to cause MCUs to reset. Especially the way you have it wired.

A better way would be to run separate Power Lines directly to the Mega, along with the Power Lines you have going to the Stepper Motor drivers. And, even better, as WattsThat suggested, avoid breadboard connects, all together, for Power Lines. Also, make sure the Power Supply voltage is not dipping.

Also, you said you're running 12V to those Stepper Motor Drivers, yet I see, on your schematic, the same power line running to the 5V pin on the Mega. Oops -- that's scary! If it's 12V, it should be running to the Vin pin! And, I hate to say it, but, you may have damaged your Mega.

And, without a code listing, it's kinda hard to advise you on what might have happened there--but it sounds like the apparent code change stimulus is a red herring :wink:

Do us a favor and read: How To Use This Forum
And: How To Embed An Uploaded Image

Thanks for the suggestions, I ended up changing the wiring so that the Arduino was directly powered by the external power source. Additionally, changing the voltage to just 5V, which allowed everything to work properly.
Thanks for your suggestions!