h bridge
DESCRIPTION
a h bridge for reversing polarityTRANSCRIPT
Parts:
Breadboard
2 NPN transistors (2N4401 or almost any general purpose NPN)
2 PNP transistors (2N4403 or almost any general purpose PNP)
Low power DC motor (3 to 9V)
Arduino
Hookup wire
Source: http://www.solarbotics.net/library/circuits/driver_4varHbridge.html
Almost any NPN and PNP transistors will do for this project, because the motor is low power. If you are short on low power
DC motors, don’t worry, they are everywhere! Specifically, if you have an old cd player, tape player, or computer cd drive,
you can usually find plenty of motors inside those devices. Be careful to choose lower power, though. It’s generally a bad
idea to source a lot of current from your Arduino. Look for any 3 to 9 volt motor for this project.
To begin, build the schematic below on your breadboard. The PNP transistors are on top, and the NPN transistors are on
bottom.
Once the build is complete, copy and paste the following code into a new sketch in your Arduino IDE:
/*
H bridge test
This is a simple test for a homemade h bridge using two
npn transistors and two pnp transistors.
There are only two control signals, we'll call them A and
B. When A is 0 and B is 1, the motor should run in one
direction. When A is 1 and B is 0, the motor should run
in the opposite direction.
*/
void setup() {
// initialize the digital pins as outputs.
pinMode(8, OUTPUT); // "A"
pinMode(9, OUTPUT); // "B"
}
void loop() {
digitalWrite(8, HIGH); // begin motion
digitalWrite(9, LOW);
delay(2000); // wait for two seconds
digitalWrite(8, LOW); // change directions
digitalWrite(9, HIGH);
delay(1000); // wait for one second
}
The project works by using a two bit input from the Arduino. When A is “1” and B is “0”, current flows as follows:
When A is “0” and B is “1”, current flows in the opposite direction:
The arrangement works because the NPN transistors allow current to flow when the base voltage is high, and the PNP
transistors allow current to flow when the base voltage is low.