h bridge

4
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

Upload: ilie-cristian

Post on 20-Dec-2015

7 views

Category:

Documents


3 download

DESCRIPTION

a h bridge for reversing polarity

TRANSCRIPT

Page 1: h Bridge

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

Page 2: h Bridge

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

Page 3: h Bridge

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:

Page 4: h Bridge

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.