Home Chapter 13 BS2 Driving your Motor with the H-Bridge
BS2 Driving your Motor with the H-Bridge

NOTE: If you want to use batteries then read the information box below.


Caution : If you decide to use batteries make sure that they have more than 6v available at all times. Anything less than 6v will not provide enough supply voltage for the 78L05. You could also power the 78L05 through the Logic Battery terminals directly, which require a minimum of 4.5 volts for proper operation.


  1. Take your multimeter and set it to 20v DC. Use the two probes to determine V+ and GND. When you find ground, wrap a piece of black tape around it.
  2. Twist the strands of each power supply wire to make them tight with no loose wires hanging out.
  3. Now get your motor control board and locate the motor V+ and GND in white silkscreen writing. Place the wires through the board, making sure no small bits of wire are touching the other wires.
  4. Check to see that your black tape is indeed closest to the GND silkscreen writing. Solder into place and clip the excess wire from underneath the board.
  5. Notice that in your kit there are also some black terminal blocks. You can choose to use these or not, depending on if you think you will want to remove the board often. I recommend not using these and going to step 6.
  6. A better idea is to use the terminal wire and select wires long enough to get from your H-bridge motor driver board to the breadboard on the Board of Education . If you need the provided black block, simply install and solder into place. 


  1. Take out your DC motor. This is a DC gearhead motor, which runs at 12v DC. Note: we will only be using one motor for the purpose of this experiment, but this board can drive two motors.
  2. Take the two pieces of thick wire that came with the kit and solder them to the motor terminals.
  3. Now solder the wires to the left side of the board as above

 Driving your Motor with the H-Bridge

Connect a wire between the Fwd terminals on the H-bridge board to PIN 0 and connect the Back terminal to PIN 1.

Remember, the underside of the circuit can be shorted easily so be careful not to rest this on a metal table or have it sitting on exposed wire.





Notice the ground wire of the H-Bridge (black wire) is also connected to the ground of the BS2. It is important to have common grounds, and this functionally attaches the ground that supplies the BS2 with power to the power supply that powers the motor and the H-Bridge motor control board.



Programming the Project and Theory of Operation
You can control the H-Bridge board and drive your motor forward or backward by grounding the appropriate control pin. This is achieved by asserting a logic LOW (0v or ground) on the output pin of your BS2. To move the motor forward, you ground the forward connection. To move the motor backward, ground the backward pin.

It is clear that you can drive this motor driver board by using the logic levels available on the BS2, however the H-bridge board can also be programmed with PWM , which means you can control the speed of the motor.

However, if you are interested in rapid PWM in the range of 60 KHz, the n you will need to use fast recovery Shotsky diodes to replace the ones supplied in the kit.


Schottky diodes are diodes which have a fast switching and have a low forward voltage drop.


Truth Table
Forward = 0, Backward = 0-- no rotation
Forward =0, Backward = 1-- clockwise rotation
Forward =1, Backward = 0-- counterclockwise rotation
Forward =1, Backward = 1-- no rotation

Driving the Motor Using Digital Logic

Enter the code below

'Logic control of the H-Bridge

' {$STAMP BS2}
' {$PBASIC 2.5}


Low 1 'turns motor clockwise
High 0


Pause 4000

Low 0 'stops the motor
Low 1

Pause 1000

Low 0 'turns counter counterclockwise
High 1

Pause 4000

Goto top

Note: If your program didn't work, there might be a communication problem between your stamp and your computer. In order to fix this problem you need to use a debug command anywhere in the program.