# Using MBED PWM for motor control

I have an mbed project with firmware that controls some PwmOut switches. All works fine firmware opens and closes switches as expected. I tested this with a LED (and resistor).

Now my goal is that instead of a light coming on, a electric brush motor (with a simple +/-) 3v-5v should run. I understand that the PwmOut from the mbed will not provide enough current to run the motor.

Will I need a transistor that connects the PwmOut port with the motor?

If yes:

• how do I know what type I need?
• these three legged guys - how are they hooked up?
• It's worth adding how much current the motor draws (or a datasheet if you're not sure). If it's a small motor you could probably use the circuit from the answer to electronics.stackexchange.com/questions/7235/… – PeterJ Nov 15 '13 at 10:20

You can follow the recipe at http://mbed.org/cookbook/Motor which uses the Motor interface for driving a standard DC motor with PWM and an H-Bridge.

If, instead of using the L293D dual H bridge driver, you want to use a transistor to drive the motor. You choose the transistor mainly by looking for a switching transistor which has a current and voltage rating that exceed the current and voltage ratings of the motor (so it depends on the motor) - for high currents you may need a heatsink for the transistor.

For a bipolar junction transistor (BJT) you'll need a resistor to limit base current. Most driver circuits incorporate a diode to prevent harm to the transistor from back-EMF from the motor windings.

The connections to a BJT are base, emitter, and collector

You can find out which leg is which by looking at the data sheet for the specific transistor you have chosen. For example

You can instead use a MOSFET, these can be more efficient (lower voltage drop when 'on')

Some rather good instructions can be found here