Hello, followers and makers alike. It's been a while and I haven't posted much. BUT...I now have something to discuss with all of you. Motors. They are very useful, but what would make them more effective is if we knew how to make them change direction without touching the wiring. How would we go about doing that? Hm....



This bizarre chip is called an h-bridge. H-bridges come in all sorts of sizes and capabilities. But for the time being, lets stick with this basic version called the TB66. This chip can drive two mediocre sized motors simultaneously, but all we will be focusing on at the time is how to control 1 motor.

As you can see, there are many pins you might not be familiar with. Do not worry. We will dissect and understand this chip so that way you can access all of its capabilities.

Step 2: The Powers and Grounds

Like most projects we have worked with, the TB66 has powers and grounds. To begin your understanding of the infamous TB66, lets see how we use these terminals.

First, you need a ground and 5v power (top left). These will be used for logic power, or power for the actual chip controlling the circuit.

Then you need a second ground and a power terminal that hooks up to a battery (bottom left). These are what will be used to power your motors, when they are actually turning. For the battery you need to use, I have found that using one 9v battery or six AA batteries are the most preferable when using this H-bridge.

Then there is the manual switch (right, middle) and a ground. What the manual switch allows you to do is force your circuit to turn off, not allowing the motors to move unless the Manual switch gets 5V. Since the circuit that we will be focussing on does not require this, we will supply 5v to the man. switch.

Step 3: Inputs and Outputs

The pins you see labeled above are what will be controlling how your motors (in this case, only one) move.

PWMA is the pin that, depending on how much signal you send to it, indirectly controls how fast your motors move. For instance, if one sends 3.3 v (2/3 of 5v) to PWMA, then the motors will move to the extent that fraction of the battery's voltage (9v), which would be around 6v.

Ain1 and Ain2 are the inputs, from the arduino**, control the direction of the motor. When using them in code, one of these inputs have to be written as LOW, and the other HIGH* when telling the motor to move. However, when telling the motor to stop, both inputs have to be LOW. These inputs don't actually send power to the motors (it wouldn't be enough) but rather represent which terminal on the motor is power and ground.

Ao1 and Ao2 are the pins that you will connect your motors terminals to. These are outputs that send the power from the battery. The way that the power is given to a motor depends on how the Ain1 and 2 are told to be. If Ain1 is LOW, then Ao1 is LOW and the same holds true for Ain2 and Ao2. Again, one output has to be LOW while the other is HIGH in order for the motor to move.


**Arduino: the chip we will be using to control the TB66

Step 4: Which Pins Correspond to Which?

Here is another way one can view the way that these input pins and output pins interact, inspired by bcraun:

Motor Pin-------------------OUTPUT------------------INPUT--------------------Arduino Pin

Motor Terminal+---------------AO1-----------------------AIN1--------------------------Pin 3

Motor Terminal - ---------------AO2-----------------------AIN2--------------------------Pin 4


Motor Pin-------------------OUTPUT------------------INPUT--------------------Arduino Pin

Motor Terminal- ---------------AO1-----------------------AIN1--------------------------Pin 3

Motor Terminal + --------------AO2-----------------------AIN2--------------------------Pin 4

See bcraun's account @:


Step 5: Corresponding Pins on the Arduino

Those familiar with my previous lessons know that the microcontroller we use is an arduino called pro Trinket (5v version).

This is the device that we will be programming and controlling the motors with. On the diagram above, I have labeled the pins on the arduino that correspond with the pins on the TB66.

Take your time in observing and noting. For our Inputs, we will be using pins 3, 4, 5.

It is now time to start constructing our circuit.

Step 6: The Parts Needed

To start constructing your circuit, you will need the following:

-One fully charged 9v battery

-One TB66

-One Pro trinket (5v version!!!)

-Wires to connect your parts together with

Done? Yeesh, you're fast! Lets start working.

Step 7: Connect the Powers

First things first, connect the essential grounds and powers. One thing to keep in mind, and this is very important:


But don't connect powers of different voltages (ex. the 5v pin and Battery pin), or else you are going to be Mr. (or Ms.) Cranky.

Like seen in previous diagrams, connect the manual switch and 5v pins to the 5v pin to the arduino.

As mentioned earlier, connect all grounds to a common ground, including the ground terminal of the battery and the ground pin of the arduino.

Connect the battery's power to the associated pin. In real life, that pin will be labeled asVmot.

Step 8: Connect the Inputs and Outputs

Connect the arduino controls as followed:

Pins 3 and 4 on the arduinowill act as our pins to connect to Ain1 and Ain2, respectively.

Pin 5 on the arduino will act as our PWMA. The speed you want your motors to be able to move at is completely your own decision.

And for the last step, connect your motor's terminals (ground and power) to Ao1 and Ao2, which will change relative to the inputs. The way you connect your motors terminals to the outputs does not matter, as long as those outputs correspond to the correct inputs.

And there you have it. You have successfully finished your own H-Bridge circuit! Welcome to the beginning of basic robotics!

Step 9: Writing the Code

For my fellow viewers and followers, we all know that in order to get the circuit to actually do anything, we have to code the circuit to do something.

Those who do not know how to do basic coding, click on the following link to see how to code an LED to blink:


For those who are curious for the code now...it's down below. Please read the built in comments to help your understanding.


void setup() {

pinMode(3, OUTPUT); //This is our AIN 1

pinMode(4, OUTPUT); //This is our AIN2

pinMode(5, OUTPUT); //This is our PWMA


void loop() {

digitalWrite(3, HIGH); // If you change this to LOW, then change the line below to HIGH

digitalWrite(4, LOW); //

analogWrite(5, 100); // *



*When you say analogWrite in arduino, you are giving an integer of 0 to 255 after the coma. Divide this number by 255, and you get the fraction of the battery you are using to power your motors. In this case, 100/255 is roughly .39, or 39% of the battery's voltage will be sent to the motors. So if you are using a 9 V battery, 3.52 V will be used.

Feel free to experiment with the code and manipulate the speed of the motor.

Step 10: For Other Tutorials

For those curious in continuing, I have made tutorials on building professional robots requiring the TB66 circuitry. Code for these codes can be found on my github account under Gears n' Genes. Please do not feel afraid to check them out and make your own code and creations.

Check it out here:


Don't forget to favorite this instructables and follow me for more lessons to inspire yourself to make creative projects.

<p>You can get a nano 3.0 cheaper, same chip :)</p>
<p>Yes... you are correct. You could. </p><p>But Adafruit's protrinket that is used here is not expensive either. It is $10.</p><p><a href="https://www.adafruit.com/products/2000">https://www.adafruit.com/products/2000</a></p>
nano 3.0 can be bought on ebay or aliexpress for . &euro; 2 or even less. That's 5 times cheaper,quite a difference. H bridges can be bought from around &euro; 1 for a dual one.
<p>That's true; it is the same Atmega 328 chip... The prices are falling down as we speak:-) great time for makers...</p>
<p>&quot;What the manual switch allows you to do is force your circuit to turn off, not allowing the motors to move unless the Manual switch gets 5V.&quot;<br><br>Hmmm, does that imply that the motors are &quot;locked&quot;, meaning that they will be dynamically breaking? If not, maybe &quot;not moving the motors&quot; or something like that would be more accurate instead.</p>
<p>Fair point, what I meant to say is that the &quot;manual switch&quot; cuts off power to the motors, causing them to stop from no power going through them, not &quot;locking&quot; them in place. Thanks for the critique. Keep up the analysis!!</p><p>:)</p>
<p>Keep up the good work with more nice tutorials! :D</p>
<p>Building a robot mower from a Jazzy mobility chair, going to use </p>Sabertooth Dual 60A 6V-30V Regenerative Motor Driver<p>since this is my first project I did a lot of research and found this is the H- Bridge it will need to handle the job</p><p> sabertooth-dual-motor-driver.html?product-code=RB-Dim-44</p>
<p>does this particular H-Bridge have current protection?</p>
<p>Dont believe so. Max current 3A, continuous 1A per channel (motor). Most hobby motors and servo motors would be fine. See below for details on specs.</p><p><a href="https://www.pololu.com/product/713">https://www.pololu.com/product/713</a></p>
very useful, thanks for sharing
<p>can I use an adafruit TB6612</p>
Yes. TB66 12fng is the full name.
<p>And the motor connects how?</p>
<p>Mot+ &lt;--&gt; AO1</p><p>Mot- &lt;--&gt; AO2</p><p>--or--</p><p>Mot+ &lt;--&gt; AO2</p><p>Mot- &lt;--&gt; AO1</p>
<p>Dude, got your chart in the edition. See if you like it. I added in INPUT and OUTPUT connections too.</p>
<p>LOVE the arrangement of data! I should probably add that into the instructables. THANKS BCRAUN!</p>
<p>Excellent information. Thanks for writing this up. Helped me get started. </p>
<p>Thank YOU.</p>
<p>it's possible work at 24V? I need to my Electric scooter </p>
<p>Hi</p><p>For a scooter, you don't need a H-bridge. (You don't need a reverse...)</p><p>Your scooter motor might be in the range of 250-500W this gives a current of 11-22 A @ 24V. This can be done with a single Mosfet with a low RDSon.</p>
<p>I do not understand electronics. My home is built scooter speed controller board but has no reverse and necessary. what can I do?</p>
<p>If you don't understand electronics, it's probably the best, if you buy a speed controller.</p><p>Something like this:</p><p>http://www.dx.com/p/maitech-ccm6dw-dc-motor-speed-controller-325731#.Vmrgq140-uQ</p>
<p>I need reverse.... </p>
<p>This can easily be done with such a switch.</p><p>http://www.dx.com/p/6-pin-on-on-toggle-switches-orange-ac-250v-2-pcs-163273#.Vmr7tF40-uQ</p>
<p>These switches I've used. very hot and melt.</p>
<p>Not with the TB66. The DRV8801 can drive a single motor 8-36V @ 1A continuous.</p>
<p>Really cool! Not a difficult circuit to build but very useful and practical.</p>
<p>Very nicely done! Thanks for sharing!</p>

About This Instructable




More by gearsngenes:Backyard Brains: A Size Down The Kinemeter: Part 3: Circuit & Code The Kinemeter: Part 2: Building the Body 
Add instructable to: