proplem in DC motor

hi guys
i get a new dc motor

can this motor move left and right and if he can how i can do this

TRY AGAIN

try what :smiley:
if he can go left and right so i nead the code :smiley:

This isn't a program writing service. This is a help forum. You write the code. We help you with it. You have to tell us what you want to learn and when. We help you learn it. If you are not willing to learn, then you are on the wrong forum. What's it going to be ?

raschemmel:
This isn't a program writing service. This is a help forum. You write the code. We help you with it.

While agreeing with that sentiment, the methods for powering motors, reversing, and even speed control are so well known that it seems a pity not to point a member to examples like this or this.

To reverse a motor you need to reverse the connections. You can either do that by hand, eg reverse the battery which is not very practical, or use an h-bridge as shown in those tutorials. You can make an h-bridge with switches. Read about h-bridges here.

AhmedMostafa:
can this motor move left and right and if he can how i can do this

I'm going to try to be a bit more helpful...

You can't do much with just the motor and the Arduino - you need some way to change the direction of current flow thru the motor. What you need is called an "h-bridge":

Now - according to this (data about your motor):

http://www.jameco.com/webapp/wcs/stores/servlet/Product_10001_10001_2150432_-1

Under "no-load" conditions, the motor will draw 190 mA of current. Unfortunately it doesn't say how much current it will draw when stalled (which is the condition when the motor starts up - not just with a load that the motor can't move, though that is the traditional meaning of the word "stall") - but you can guesstimate about 5 times or so of the "no-load" current, or about 1 amp in this case.

You want an h-bridge that can handle this amount of current - not the "no-load" current. You will also need a power source that can provide that much current to the motor, at the necessary voltage.

Now - I know that the specs say the motor requires about 4.5 volts to run; in reality these small motors can take a bit more, with maybe a little decrease in life. The thing is, commonly available h-bridges that you can typically purchase inexpensively (I'm talking L293 and L298 based h-bridges) tend to require more than that to run the motor - but they also tend to consume a couple of volts as well. So - if you can supply about 7 volts through one of those h-bridges, you'll be good.

As an example of those kinds of h-bridges (note - I have no connection to any vendor - just pulling an example):

L293:

http://www.sainsmart.com/sainsmart-l293d-motor-drive-shield-for-arduino-duemilanove-mega-uno-r3-avr-atmel.html

L298:

If you purchase either of those - be sure to download the datasheets for the L293 or L298 IC so you can understand how it works better.

As for your voltage source - since you need about 7 volts - use a 7.2 volt RC battery pack - like:

http://www.amazon.com/Racers-Edge-7-2V-1500mAh-Battery/dp/B000JCNAR4/

Note that you'll need a special charger to charge the battery before your first use of it, so that will factor into the cost. You could try to build a battery pack if you wanted - using AA batteries and a holder; 6 alkalines will get you a 9 volt pack, and you can tap off at the 5 battery point for 7.5 volts (use the full 9 volts into the barrel jack of the Arduino to power the Arduino).

Alternatively, Pololu has some capable h-bridges that are more efficient; in that case, you could probably get away with a 4 cell AA pack (6 volts on alkalines):

That's one (and probably the best) example they sell.

Code for driving these is very simple - but I'll leave that as an exercise for you to research and/or experiment with. Suffice to say, now that you know the circuit is called an "h-bridge" - you should be able to google something to find examples fairly easily.

Good luck with your project.

I second cr0sh on that Pololu 2130: I have one and it's excellent. Main thing about it is its size, it's tiny, and it doesn't require a heatsink the size of a barn door. Its wiring is a bit simpler than 293/298 since there's no explicit enable pin, and for speed you just pwm 1 of the 2 inputs.

You have to tell us what you want to learn and when (in what order). We will help you learn it.

I agree. Some kind of motor shield or driver (pcb or shield) is required and buying one already made is easier than breadboarding an L293,
which seems to throw so many people off. (at least 30% of all Newbies have problems with breadboarded L293s , usually because they haven't read the datasheet or don't understand how an H-bridge works)