So, you’re planning to build your own two-wheel-drive robot? That’s awesome! One of the most important steps in bringing your robot to life is choosing the right motor driver.
If you’ve already done some searching, you’ve probably come across classic motor drivers like the L293D or L298N. These have been around for over two decades and are still widely used today—for good reason. They’re simple to use, reliable, and very affordable, which makes them especially popular in schools, hobby projects, and beginner electronics kits.
But here’s the thing: both the L293D and L298N use BJT-based H-Bridge circuits, which aren’t very energy efficient. They waste power as heat, require higher voltages, and are not ideal for battery-powered projects.
That’s where the TB6612FNG motor driver comes in. This is a modern, MOSFET-based driver that offers several advantages. It’s more efficient, so it runs cooler and wastes less power. It works at lower voltages, which makes it perfect for 3.3V and 5V logic boards. It also has a smaller footprint, making it ideal for tight spaces in robots, drones, and other compact projects.
In this tutorial, you’ll learn everything you need to know to hook up an TB6612FNG motor driver to your Arduino, control both the speed and direction of two DC motors, and get your robot rolling in no time.
Let’s get started!
Understanding Motor Control Basics
Before learning about the TB6612FNG motor driver, it’s important to understand two key concepts:
- H-Bridge circuit – allows us to control the direction of the motor’s rotation
- PWM (Pulse Width Modulation) – helps control the speed of a DC motor
Controlling Direction with an H-Bridge
DC motors are the easiest motors to use! If you connect a battery to a DC motor, it will spin in one direction. If you swap the wires, it spins in the other direction. But you can’t always physically swap the wires every time you want to change direction. That’s where an H-bridge comes in handy!
An H-bridge is a special circuit with four electronic switches arranged in an “H” shape, with the motor in the middle.
By turning these switches on and off in a specific order, you can make electricity flow through the motor in one direction or the opposite direction. This clever trick lets you control which way the motor spins without having to physically reverse any wires.
The animation below shows how an H-bridge works.

Controlling Speed with PWM (Pulse Width Modulation)
When a fixed voltage is given to a DC motor, it spins at a fixed speed. If you want to change the speed, you need to adjust the voltage. A higher voltage makes the motor spin faster, while a lower voltage makes it slower.
However, physically changing the voltage all the time isn’t very practical. That’s where PWM, or Pulse Width Modulation, comes in.
PWM is a smart way to control the average amount of power sent to the motor. Instead of sending a fixed voltage, PWM rapidly turns the voltage ON and OFF in very quick pulses.
The “width” of each ON pulse, also called the duty cycle, determines how long the voltage is “ON” during each cycle.
- If the voltage is ON for most of the time (a wider pulse), the motor receives a higher average voltage and spins faster.
- If the voltage is OFF for most of the time (a narrower pulse), the motor receives a lower average voltage and spins slower.
The image below shows how different duty cycles affect motor speed.

TB6612FNG Motor Driver Chip
The TB6612FNG is primarily designed for driving inductive loads such as DC motors, stepper motors, relays, and solenoids.
It works as a current amplifier, meaning it takes the low-current control signals from a microcontroller (like an Arduino) and boosts them to the higher current and voltage levels that motors need to operate.

At its core, the TB6612FNG has two separate H-bridge circuits. So, it can control two different DC motors at the same time. You can even combine these two H-bridges to control a bipolar stepper motor.
Power
The TB6612FNG is pretty flexible when it comes to power. It can work with a wide range of voltages, from 4.5V up to 13.5V, and can supply up to 1.2A of continuous (and 3.2A peak) current per channel, which means it can handle everything from small hobby motors to larger, more powerful ones.
Built-in Flyback Diodes
One of the most important safety features of the TB6612FNG is its built-in flyback diodes (also called freewheeling or kickback diodes). These are very important when working with inductive loads like motors.
When you suddenly turn off a motor, its magnetic field collapses. This can send a voltage spike back into the circuit. This backward voltage (called back EMF or Electro-Motive Force) can damage your microcontroller or other sensitive components.
The flyback diodes in the TB6612FNG give this dangerous backward current a safe path to flow, protecting both the IC and the rest of your circuit.
Thermal Protection
The TB6612FNG also includes built-in thermal protection. This means that if the chip gets too hot — maybe because a motor is drawing too much current or the chip isn’t cooled well — the TB6612FNG will automatically shut down its outputs temporarily to prevent damage. Once the chip cools down to a safe temperature, it automatically starts working again.
Technical Specifications
Here are the specifications:
| Motor output voltage | 4.5V – 13.5V |
| Logic input voltage | 2.7V – 5.5V |
| Continuous current per channel | 1.2A |
| Peak current per channel | 3.2A |
| Maximum PWM Frequency | 100kHz |
| Max Power Dissipation | 0.78W |
For more details, please refer below datasheet.
TB6612FNG Motor Driver Module Pinout
The TB6612FNG module has 16 pins in total.

Let’s go over each group of pins to understand what they do and how to use them properly.
Power Pins
There are two power input pins on the TB6612FNG module: VM and VCC.

VM is the main power input for the motors. You can connect any voltage between 4.5V and 13.5V, depending on the motor you are using.
VCC is the power input for the internal logic circuitry of the chip. The acceptable voltage range for this pin is between 2.7V and 5.5V, so it works well with both 3.3V and 5V microcontrollers. Just make sure that the voltage you supply to this pin matches the logic level of the microcontroller you’re using. For example, if you’re using an Arduino, which typically works with 5V logic, then you’ll want to connect VCC to a 5V source.
GND pin is the common ground connection for the module. Both the motor power supply and your microcontroller (like an Arduino) must share a common ground through this pin.
Motor Output Pins
These are the pins where you actually connect your DC motors.

The A1 and A2 pins connect to your first motor (motor A), while the B1 and B2 pins connect to your second motor (motor B). You can connect any DC motor that runs on 5 to 13 volts to these pins.
Direction Control Pins
These pins control the spinning direction of the motors by turning the internal H-Bridge switches on and off:

The chip has two direction control pins for each motor. The AIN1 and AIN2 pins control the spinning direction of motor A, while the BIN1 and BIN2 pins control the spinning direction of motor B.
By setting different combinations of HIGH or LOW signals on these pins, you can make the motors spin forward, backward, or stop. The chart below shows exactly how this works:
| Input1 | Input2 | Spinning Direction |
| Low(0) | Low(0) | Break |
| High(1) | Low(0) | Forward |
| Low(0) | High(1) | Backward |
| High(1) | High(1) | Break |
Speed Control Pins
The PWMA and PWMB pins control how fast your motors spin.

Actually, these pins work as simple on/off switches. When you pull one of them HIGH, the corresponding motor is enabled and spins at full speed. When you pull it LOW, the motor is completely disabled and won’t spin at all.
But these pins can do more than just switch the motors on or off. By sending a PWM (Pulse Width Modulation) signal with a frequency up to 100kHz to PWMA or PWMB, you can actually control the speed of each motor.
PWM works by turning the motor on and off very quickly—many times per second. The speed depends on how long the motor stays on during each cycle (called the duty cycle). If the signal stays on for most of the time, the motor spins faster. If it’s on for only a short time, the motor spins slower.
Standby Pin
The STBY pin allows you to quickly disable both motors at the same time.

By default, this pin is pulled low by an internal 200K ohm pull-down resistor, which keeps the motors disabled. To enable the motors on and allow them to operate, you must pull this pin HIGH. You can do this by either connecting the pin directly to the VCC or by using an output pin from a microcontroller to drive it high.
Wiring an TB6612FNG Motor Driver Module to an Arduino
Now that we know how the TB6612FNG module works, we can start connecting it to our Arduino!
We’ll begin by connecting power to the motors. In this experiment, we’re using TT motors which are commonly used in two-wheel drive robots. These motors usually work well with voltages between 3V and 6V. So, we’ll connect an external 5V power source to the VM pin.
Next, we need to supply logic power to the driver’s internal circuitry. The VCC pin on the TB6612FNG module expects a 2.7V–5.5V input, which matches the Arduino’s 5V output. So, connect the Arduino’s 5V pin to VCC, and GND to GND.
Now let’s handle the control pins. The TB6612FNG module has four input pins—AIN1, AIN2, BIN1, and BIN2—that are used to control the direction of the motors. We’ll connect them to digital output pins 5, 4, 7, and 8 on the Arduino.
To control motor speed, the TB6612FNG has PWM input pins labeled PWMA and PWMB. These should be connected to Arduino PWM-capable pins—3 for PWMA and 9 for PWMB.
You’ll also need to connect the STBY pin to a logic HIGH level in order to enable the motor driver. In our setup, we’ll simply connect it directly to VCC. This is a very important step—if you forget it, the motor driver will stay in standby mode, and the motors won’t run at all.
Finally, connect your motors to the output pins. Motor A goes to A1 and A2, while Motor B goes to B1 and B2. Don’t worry too much about which motor wire goes to which output pin—if your motor spins in the wrong direction, you can simply swap the wires later, as there’s no “right” or “wrong” way to connect them.
Here’s a quick reference table for the pin connections:
| TB6612FNG Motor Driver | Arduino | |
| VCC | 5V | |
| STBY | 5V | |
| GND | GND | |
| PWMA | 3 | |
| AIN2 | 4 | |
| AIN1 | 5 | |
| BIN1 | 7 | |
| BIN2 | 8 | |
| PWMB | 9 |
The image below shows the complete wiring diagram for this setup.

Arduino Example Code
Here’s a simple Arduino sketch that shows how to control the direction and speed of two DC motors using the TB6612FNG motor driver and an Arduino. You don’t need any special libraries for this sketch; it uses only the basic built-in functions of the Arduino IDE.
This example is a great way to get hands-on experience with using the TB6612FNG to control both speed and direction of motors. Once you understand this, you can easily build more complex motor control systems, like those used in basic robots or remote-controlled cars.
// Motor A connections
int pwmA = 3;
int Ain1 = 5;
int Ain2 = 4;
// Motor B connections
int pwmB = 9;
int Bin1 = 7;
int Bin2 = 8;
void setup() {
// Set all the motor control pins to outputs
pinMode(pwmA, OUTPUT);
pinMode(pwmB, OUTPUT);
pinMode(Ain1, OUTPUT);
pinMode(Ain2, OUTPUT);
pinMode(Bin1, OUTPUT);
pinMode(Bin2, OUTPUT);
// Turn off motors - Initial state
digitalWrite(Ain1, LOW);
digitalWrite(Ain2, LOW);
digitalWrite(Bin1, LOW);
digitalWrite(Bin2, LOW);
}
void loop() {
directionControl();
delay(1000);
speedControl();
delay(1000);
}
// This function lets you control spinning direction of motors
void directionControl() {
// Set motors to maximum speed
digitalWrite(pwmA, HIGH);
digitalWrite(pwmB, HIGH);
// Turn on motor A & B
digitalWrite(Ain1, HIGH);
digitalWrite(Ain2, LOW);
digitalWrite(Bin1, HIGH);
digitalWrite(Bin2, LOW);
delay(2000);
// Now change motor directions
digitalWrite(Ain1, LOW);
digitalWrite(Ain2, HIGH);
digitalWrite(Bin1, LOW);
digitalWrite(Bin2, HIGH);
delay(2000);
// Turn off motors
digitalWrite(Ain1, LOW);
digitalWrite(Ain2, LOW);
digitalWrite(Bin1, LOW);
digitalWrite(Bin2, LOW);
}
// This function lets you control speed of the motors
void speedControl() {
// Turn on motors
digitalWrite(Ain1, LOW);
digitalWrite(Ain2, HIGH);
digitalWrite(Bin1, LOW);
digitalWrite(Bin2, HIGH);
// Accelerate from zero to maximum speed
for (int i = 0; i < 256; i++) {
analogWrite(pwmA, i);
analogWrite(pwmB, i);
delay(20);
}
// Decelerate from maximum speed to zero
for (int i = 255; i >= 0; --i) {
analogWrite(pwmA, i);
analogWrite(pwmB, i);
delay(20);
}
// Now turn off motors
digitalWrite(Ain1, LOW);
digitalWrite(Ain2, LOW);
digitalWrite(Bin1, LOW);
digitalWrite(Bin2, LOW);
}When you speed up or slow down a DC motor, you might hear a humming sound, especially at lower PWM values. Don’t worry—this is completely normal. It happens because DC motors need a certain minimum amount of voltage to start spinning, and at low PWM values, the voltage might not be high enough to keep the motor operating smoothly.
Code Explanation:
At the start of the sketch, we define which Arduino pins will be used to control Motor A and Motor B.
// Motor A connections
int pwmA = 3;
int Ain1 = 5;
int Ain2 = 4;
// Motor B connections
int pwmB = 9;
int Bin1 = 7;
int Bin2 = 8;In the setup() function, we configure all six motor control pins as outputs, because we are sending signals from the Arduino to the TB6612FNG. We also make sure that both motors are turned off by setting all the direction control pins to LOW. This ensures the motors don’t suddenly start spinning when the Arduino powers on.
void setup() {
// Set all the motor control pins to outputs
pinMode(pwmA, OUTPUT);
pinMode(pwmB, OUTPUT);
pinMode(Ain1, OUTPUT);
pinMode(Ain2, OUTPUT);
pinMode(Bin1, OUTPUT);
pinMode(Bin2, OUTPUT);
// Turn off motors - Initial state
digitalWrite(Ain1, LOW);
digitalWrite(Ain2, LOW);
digitalWrite(Bin1, LOW);
digitalWrite(Bin2, LOW);
}In the loop() function, we call two custom functions with a delay of one second between them. The first function is directionControl(), and the second is speedControl().
void loop() {
directionControl();
delay(1000);
speedControl();
delay(1000);
}Let’s break down what each of these functions does.
The directionControl() function demonstrates how to control the direction of both motors. First, we set both motors to their maximum possible speed by setting both PWM pins to HIGH. Then, we send the necessary signals to the direction control pins to make both Motor A and Motor B spin forward. After they spin in that direction for two seconds, we change the signals to their direction pins, which causes both motors to reverse their spinning direction for another two seconds. Finally, we stop the motors by setting all direction control pins to LOW.
void directionControl() {
// Set motors to maximum speed
digitalWrite(pwmA, HIGH);
digitalWrite(pwmB, HIGH);
// Turn on motor A & B
digitalWrite(Ain1, HIGH);
digitalWrite(Ain2, LOW);
digitalWrite(Bin1, HIGH);
digitalWrite(Bin2, LOW);
delay(2000);
// Now change motor directions
digitalWrite(Ain1, LOW);
digitalWrite(Ain2, HIGH);
digitalWrite(Bin1, LOW);
digitalWrite(Bin2, HIGH);
delay(2000);
// Turn off motors
digitalWrite(Ain1, LOW);
digitalWrite(Ain2, LOW);
digitalWrite(Bin1, LOW);
digitalWrite(Bin2, LOW);
}The speedControl() function demonstrates how to control the speed of the motors using PWM. We start by setting the direction control pins so that both motors spin in one direction. Then, we slowly increase the motor speed by gradually raising the PWM value from 0 to 255. This simulates an acceleration effect. Once the motors reach full speed, we reverse the process—slowly decreasing the PWM value from 255 back to 0, which causes the motors to gradually slow down and stop. Finally, we stop the motors by setting all direction control pins to LOW.
void speedControl() {
// Turn on motors
digitalWrite(Ain1, LOW);
digitalWrite(Ain2, HIGH);
digitalWrite(Bin1, LOW);
digitalWrite(Bin2, HIGH);
// Accelerate from zero to maximum speed
for (int i = 0; i < 256; i++) {
analogWrite(pwmA, i);
analogWrite(pwmB, i);
delay(20);
}
// Decelerate from maximum speed to zero
for (int i = 255; i >= 0; --i) {
analogWrite(pwmA, i);
analogWrite(pwmB, i);
delay(20);
}
// Now turn off motors
digitalWrite(Ain1, LOW);
digitalWrite(Ain2, LOW);
digitalWrite(Bin1, LOW);
digitalWrite(Bin2, LOW);
}
