Motor Test

I am new to programming and needed help creating a simple program to test 2 DC geared motors using the Arduino Mega. I just want to spin the motors forward and backward for a certain amount of time. Can anybody help me?

Yes, somebody can help you.

See, that helps you about as much as your post helped us to understand your problem. What motor, how do you interface with them, what kind of hardware do you have etc.

If the answer to any of those questions is "I don't know", go out, research the matter and come back once you have the answers ready.


to 12 v dc motors by bison 1/8 hp 10.2 amps 40rpm gearmotors
i have them connected to a pololu md03a motor card which connects to my mega

To control the motors in both directions, you need to use an H-bridge. By the sound of those motors, choose some good hefty low on resistance MOSFETs!

This is a nice H-bridge design: The Using MOSFETS Website: H-bridge using P and N channel FETs

For the software, have a look at Project 24 Hypnotizer disc, source code on the downloads tab here:

There is also a simplified H-bridge design in the book.

i have them connected to a pololu md03a motor card which connects to my mega

If you want that board to work with those motors, you are going to want to heat sink that motor driver. It should work for the application (however, you didn't say whether that 10+ amp rating was the continuous running rating, or the stall rating - you need to know both).

Can you show us how you have the driver board hooked up, so we know that it is hooked up right before we get to the coding part? Also, have you written any code in an attempt to get it to work (even if the code is no good, its a starting point)?

If not - then first, double check your connections, then try to add a heat sink if you can to the board (with thermal grease or thermal glue and good contact, etc - just like a PC CPU). Without it, you might get it to run for a few seconds, but then the overcurrent/overheating protection on the chip will kick in and shut things down until they cool. You also want to make sure that the stall current (also called the "starting current") is not greater than the 30A that motor driver can supply. If it is, then you could have everything correct, from the wiring to the code, but as soon as it tried to start it, it would kick off from the overcurrent protection.

So - do all those things, then try to write some code; the PWM connections on the board will need to be run to the PWM pins on the Arduino, or to a couple of digital pins (if you want to attempt to create your own PWM output).

Then post back here with everything you have, and we can see what we can help with, hopefully...