How to change the voltage coming from arduino

I am using some motors in my project, I was wondering if there is a way to control the output voltage from the arduino. So I can control the speed of the motor.

Normally to preserve the torque produced by the motor, it is still fed the full voltage, but the voltage is pulsed on and off quickly. This is called Pulsed Wave Modulation (PWM). Basically to control the speed of the motor you need to simply use the analogWrite() command. Do however be advised that motors should not be driven directly from the output pins of the Arduino.

Do however be advised that motors should not be driven directly from the output pins of the Arduino.

Why is that? Is it to ensure that the motor doesn't draw too much current and fry the Arduino?

yes

How should I connect the motors to the board than? Right now I have them connected directly to the 0-3 pins on the board, and sending each analogWrite(.....,200);

How should I connect the motors to the board than?

I would use either Transistors or Relays.

More info on Motors and the Arduino:

http://www.thebox.myzen.co.uk/Workshop/Motors_1.html

Or an H-Bridge...

Or an H-Bridge...

Well, yes, that would work too. I was merely providing my preferences ;).

Maybe your test connecting motors to outputs 0-3 is working now, perhaps because you are using low torque motors without any mechanical load. But if you charge the motor surely you will damage arduino outputs. Many options: -Use stepper motors. Speed can be fully controlled. Need transistors or bridge -Use DC motors. Use PWM (Pulse Width Modulation). Speed is controlled although not as precisely as with steppers. Needs also transistors or bridge

Also when the magnetic field on your DC motor collapses it can cause damaging back current to the arduino... thus its best to isolate it.

Read this from Grumpy_Mike: http://www.thebox.myzen.co.uk/Workshop/Motors_1.html

Chris

I read the provided links and do not understand how transistors work. This is the motor I am using http://www.sparkfun.com/commerce/product_info.php?products_id=8911

First:

read this Motors 1
as suggested in a previous post, very important knowlede here!

Then decide :

Do you need to control only the speed of the motor, or also the direction (forward AND reverse) ?

If you need direction control you need to use an H bridge. Check this.

http://itp.nyu.edu/physcomp/Labs/DCMotorControl.

If you need only speed control in one direction you can do it like this:

What if I need to control speed and direction?

If you need direction control you need to use an H bridge. Check this.

http://itp.nyu.edu/physcomp/Labs/DCMotorControl.

\

With that, you can control both speed and direction.

Ok, so I set up two H-bridges to control the direction of four gear-motors. Now how can I can control the speed?

By using PWM... Use the AnalogWrite() command on the pins you have attached to your H-Bridges... Just be sure they are the PWM enabled Arduino pins.

You need one H bridge per motor, 4 in all, if you want independent direction and/or speed control.

Fortunately, H bridges are widely available as single chips (sometimes 2 on a chip) that are quite easy to use. Just make sure you order enough :-)

which pins from the h-bridge do I connect to the PWM?

That would depend on which H-Bridge you have.

This is the one I have…

I was following the basic instructions at http://itp.nyu.edu/physcomp/Labs/DCMotorControl
but with 4 motors.