I have a Jameco ReliaPro (P/N 253446) DC Motor with Gearhead. I am wondering what the basic code is to start the arduino code. I have connected a servo and made it respond to a PING sensor just fine, but realized that I don't need a servo and am trying to get this motor to work instead. Is it an easy switch? I'm fairly new to arduino and am not sure if there's an existing example I can just manipulate. Any help or direction is greatly appreciated!
Got a link for the motor?
Is it an easy switch?
Fundamentally yes. You need some circuit to drive the motor, you can't connect it directly to the arduino pin.
Since you are replacing the function previously held by a servo, are you expecting position control? The motor looks pretty basic, so just about any option would work. If you need only one direction, a transistor would be fine. If you need both directions, you need an h-bridge, motor shield, or H-Bridge IC (L298, etc...)
The code will vary depending on how you drive it, whether it needs forward or reverse, and whether you need position feedback, etc...
I don't need position feedback, but I do want it to go forward and backwards depending on increasing or decreasing distance sensed by the ping.
What do you mean by you need a circuit to drive the motor? I have attached it to the power and digital input and it rotates on its own. Is this wrong?
Thanks for all the input!
Well, you are probably sinking a bit too much current through your arduino which will probably damage it. Your motor is a 12V motor. You are running it from a digital pin and 5V power. It will move, but probably not well.
The way you have it hooked up now, how do you intend to reverse the direction? If you don't care, or think I am full of crap talking about damaging your arduino, you could connect both leads to separate digital pins and pull one low and the other high for one direction, and then swap them for the other. I am definitely NOT recommending that. As it is, you are going to eventually damage your arduino. Why do you think there are H-bridges? There are other ways using high-side and low-side drivers that will work, but honestly a motorshield or an H-bridge IC is the way to go.
At the moment, I don't know what the best way to go about this. I'm pretty new to arduino and have the project in mind and am trying to find the best solution. I can look into the motorshield but still don't have the code to move it forward and backwards. I'm trying to see if this is even possible or if I should stick with a servo. I'm lifting a lot of weight and think a DC Motor would be better and cheaper, unless this can't be figured out to work with the PING. Definitely don't think you are full of crap, just don't know what to do.
It will definitely work, but you are asking for someone to help with code for hardware you haven't even picked out yet. The code will entirely depend on what motorshield or H-bridge IC you use, or H-bridge you build. I think you need to focus on that first, then after you have something come back and ask for help with code. There is TONS of code examples out there for all different types of control methods for motors. If you buy a shield, the vendor will usually have example code on their site. One popular such place is www.adafruit.com.
A servo would actually provide alot of power if you get the right sized servo. I can tell you that you are definitely unlikely to get alot of power out of the jameco motor trying to run it on 5V.
It's up to you. Either a larger servo and do it that way, or find a motor-shield, etc... and come back asking for help with code. You are just too early in the project to ask for specific examples of code to help you. The hardware comes first.
Thank a lot for the help.
Have a look at this for the fundamentals of driving a motor:-
http://www.thebox.myzen.co.uk/Workshop/Motors_1.html