H-Bridge Circuit DC motor Driver

Let's improve the basic motor driver and build a circuit that allows to control the direction of the motor.

The motor that we will be controlling can handle 12V and a maximum current (Imax) of 500mA.

If I connect the motor directly to a power supply and apply 12 V and no load on the shaft, the motor will run freely with a current less then Imax.

Motor directly connected to a power supply with no load on the shaft

With this configuration I am not able to control the motor with a microcontroller. I need to include some sort of switch that allows to turn on and off the current that flows through the motor.

Transistors are good candidates to be used as switches to control the current that flows through the motor. There are different types of transistors but we will focus on using MOSFETs for this motor driver.

H-Bridge with MOSFETs


In order to control the direction of a motor I need to find a way to change the direction of the current that flows through the motor. One way of doing that is by using an H-Bridge circuit. An H-Bridge is a transistor-based circuit capable of driving motors both clockwise and counter-clockwise.

Let's use power MOSFETs for the H-Bridge circuit. We will be using the N-Channel MOSFET IRF630 and the P-Channel MOSFET IRF9630. Because they are power MOSFETs they can handle a lot of current flowing through them and for sure meet the maximum current specs for our motor (500 mA).

N-Channel Power MOSFET - Maximum Current
P-Channel Power MOSFET - Maximum Current

MOSFETs are controlled by voltage. So as long as the MOSFETs are TTL compatible (transistor Vgs turns on at 5V or 3.3V) then we are in good shape to connect the microcontroller ouput pins directly to the transistors.

H-Bridge Motor Driver

This is one example of connecting P-Channel and N-Channel MOSFETs to build an H-Bridge motor driver. The terminals in blue will connect to a microcontroller. Now we only need to make sure that we follow table below in order to control the motor direction without damaging the transistors.

Transistors States

Do we need heatsinks on the MOSFETs?

To understand if we need heatsinks we need to do the following steps:

  • Look for the RDS on the respective datasheet. Keep in mind that RDS will vary with Vgs. So the limit (or Max) stated in the description of the MOSFET, may not apply to your circuit.
Datasheet - RDS value
  • Once you know the on-resistance, you can use your maximum load's current (500mA) to calculate how many watts the MOSFET will dissipate.
Transistor Power Dissipation
  • Now let's calculate the maximum power dissipation that transistor can handle without heatsink. Look for the maximum junction-to-ambient temperature and maximum junction-to-case temperature.
Thermal Resistance Ratings
  • Apply the following formula:
Maximum Power Dissipation

Because Pn and Pp is less than PD there is no need for a heat sink. If Pn and Pp were bigger than PD, you will need a heatsink.


Using Multisim Live we can validate the circuit.

Q1 & Q4 On / Q2 & Q3 Off
Q1 & Q4 Off / Q2 & Q3 On

We are able to reverse the current that flows through the motor.


Arduino Code

We will be using the serial monitor of the Arduino IDE and send commands to control the direction of the motor.

  • Character 's' -> stop the motor
  • Character 'f' -> motor rotates one direction
  • Character 'b' -> motor rotates opposite direction
Variables and Setup Function
Main Loop
Motor Functions


With this circuit we can turn on an off a motor, we can control the motor speed and we can control the motor direction.

Created By
Goncalo Fernandes Pereira Martins


Created with an image by Michael Dziedzic - "Motherboard, Reverse Detail: This is a green motherboard, photographed with red-gelled flashes."