# What Is an H-Bridge?

An H-bridge is a simple circuit that lets you control a DC motor to go backward or forward.

You normally use it with a microcontroller, such as an Arduino, to control motors.

When you can control two motors to go either forward or backward – you can build yourself a robot!

## H-Bridge concept

Here’s the concept of the H-bridge:

A DC motor spins either backward or forward, depending on how you connect the plus and the minus.

If you close switch 1 and 4, you have plus connected to the left side of the motor and minus to the other side. And the motor will start spinning in one direction.

If you instead close switch 2 and 3, you have plus connected to the right side and minus to the left side. And the motor spins in the opposite direction.

## The H-Bridge circuit

You can build an H-bridge with four transistors.

If you’re not sure how the transistor works, I recommend you read the article How Transistors Work first. From there you’ll learn that the transistor can work as a switch that you can open and close with the voltage on the base.

Since the transistor can be a switch, you’ll be able to make the motor spin in either direction by turning on and off the four transistors in the circuit above.

Usually, you control the transistors from a microcontroller, such as Arduino.

## What Transistors To Use?

The transistors you choose must:

• Handle enough current
• Use PNP (or pmos) at the top
• Have a low voltage drop between collector and emitter

### Current

The most important thing is that all the transistors can handle enough current for the motor. Otherwise it will burn out.

For example, if the motor draws 1 Ampere of current, you need transistors that can handle a minimum of 1 Ampere.

### PNP (or pMOS) transistors at the top

Next, you see I have chosen PNP transistors on the top, and NPN transistors on the bottom.

What turns the transistor on or off is the voltage difference between the base and the emitter.

With PNP transistors at the top, you can use a higher voltage for VCC than you use for the base of the transistors.

For example, you can use 3.3V outputs from a microcontroller and 9V for Vcc.

That won’t work if you have NPNs at the top since the emitter will be 0.7V lower than the base. Because that turns into 3.3V – 0.7V = 2.6V at the positive side of the motor, no matter what VCC voltage you choose.

### Low voltage drop between collector and emitter

While building a robot in Colombia, I tried to make this circuit using TIP120 and TIP127 transistors.

That did not work.

TIP12x transistors give a 2V drop from the emitter to collector.

In such a configuration, you’d end up with a loss of 4V over the transistors. I was trying to connect this to an Arduino, using its 5V supply, but failed because it was only 1V left for the motor!

Here’s a nice article/rant about the topic: Stop using antique parts!

Basically, it says that the TIP transistors are antiques that you shouldn’t use anymore exactly because of this huge voltage drop.

Choose transistors with low voltage drop. For example BD135/BD136 or MOSFET transistors.

## Protection diodes and PWM mode

A side-effect of how a motor works is that the motor will also generate electrical energy. When you disable the transistors to stop running the motor, this energy needs to be released in some way.

If you add diodes in the reverse direction for the transistors, you give a path for the current to take to release this energy. Without them, you risk that the voltage rises and damages your transistors.

The resistors going into each base is there to reduce the current to each transistor. Not sure how to calculate it? If you’re using a microcontroller to control them, start with 1k and adjust if that doesn’t work.

Have you built an H-bridge before? Or do you have questions about the H-bridge? Let me know in the comments field below:

## More Transistors Tutorials

### 29 thoughts on “What Is an H-Bridge?”

1. Thank you, this was very informative!

Oyvind

• Sadly in my experience a Mosfet can only be used as a Drain, rather that a source, try it, simply place your motor and a N- Channel Mosfet on a bread board, Using the Vcc connected to the Motor, and ground, then reverse the Motor connections, placing the gnd to the M/F source pin, and Motor to Vcc……

• It might run, but try and control the motor, wont happen!

• All this talk about BJT vs MOSFET & not 1 circuit discription nor circuit using MOSFETS.
Whereas you could have just used a suitable MOSFET that would be far sufficient enough to run any Voltage requirement & has inbuilt Diodes to prevent Electromagnet Current return from the motor.

2. Nice clear explanation. You might want to add a caution about not turning on both left or both right transistors at the same. That would give you a short across your transistors.

In a similar vein, controlling with an Arduino, make sure that the default outputs turn all 4 transistors off while in reset. Lastly, make sure to send commands to Turn Off the transistors before sending commands to Turn On transistors. Again, you don’t want to short out your transistors

• Good points!

Thanks
Oyvind

• What will happen to the transistors when the motor turn clockwise and counter clockwise on the other hand.

• I think that transistors Q1 and Q4 will be engaged for one direction of the motor and then to reverse the direction of the motor Q1 and Q4 will be disengaged and Q2 and Q3 can then be engaged to run the motor in the reverse direction. If the motor is manually turned and there is enough residual magnetism in the motor windings to produce a current the diodes D1 thru D4 will shunt this current off to protect the transistors.

3. Great article, explained in very simple and effective manner. Just following suggestions:

– Would be good to mention 3.3 V is being applied at base
– How to select Diode
– Calculation to select the resistor value

• All good suggestions, thanks!

Oyvind

4. May I know what is h bridge

• It allows a dc motor to either move in forward or backward direction. As you don’t want yourself to change the wires of the motors if you want to move your car in opposite direction. ;)

5. Is it possible to make it with just npn or pnp transistors.
Thanks a lot for tgis great article.

• Thanks to you for contributing =)

Oyvind

6. Thanks a lot, this was very much useful and informative.

7. we need a charge storing element like a capacitor for the switches to function this way right??

8. Oh! This is so educative that the explanation was just storing into my number 6… Thanks so much, Oyvind. But a question sir, does this circuit automatically amplify power from Arduino output? Because I think if one connects a motor to Arduino, it will run but slowly.

• Glad you liked it! An H-bridge does not take power from the Arduino, but from the power supply. The Arduino only controls the on/off of the motors.

9. hi , why are h bridge circuits used rather than connecting the pwm signal directly to motor ,
thanks

• If you connect a PWM signal directly to a DC motor, you could control the speed, but not the direction.

Also, the PWM signal is usually given by a microcontroller which won’t be able to give enough current to drive the motor.

10. In last figure what does the operation of the four transistors. By supplying +vcc to the motor right pin it will turn clockwise and – VCC for counter clockwise at the right pin of the motor. What will happen to the four transistors when the motor turn clockwise and counter-clockwise on the other hand.

• To go in one direction, turn on transistor 1 and 4. To go in the other direction, turn on transistor 2 and 3.

If you try other combinations, you’ll risk shorting your power supply, so that’s something you should avoid.

11. What will happen to the transistors when the motor turn clockwise and counter clockwise on the other hand.

• If you try to make the motor go in both directions at once you basically short circuit the power supply. The transistor might go up in smoke from all the current that will pass through them.

12. Excellent article! When using an arduino or similar, make sure to turn off the circuit that is driving the motors before changing the direction of the motor. You would do that in your program, perhaps with the delay() function, but also turns off any other processing going on as well, there are other ways to turn the outputs off.

Make sure to examine at least a few use cases, for example:
1. Motor forward mode, change to Motor reverse mode. This use case is important as pointed out this could short your transistors.
2. Overload, if the motor stalls, can you detect it? Will there be “back” EMF or voltage that could damage the circuit. If you are using a device with an IMU like the Intel Arduino 101 board or similar you could detect the lack of motion and turn off the motors with no additional hardware.

And so forth. But this article was short and a excellent refresher.