TB6612FNG Arduino Guide: Wiring, STBY Pin, PWM and Robot Code
TB6612FNG Arduino guide: less voltage drop than the L298N, STBY pin, PWM speed control, 1.2 A current, ESP32 and Pico wiring table and line follower code.
The TB6612FNG with Arduino is one of the most practical ways to drive two DC motors with very little loss. This small Toshiba chip contains two MOSFET H-bridges: each channel controls the direction and speed of one motor independently and delivers 1.2 A continuous and 3.2 A peak current. Instead of the 2–3 V drop of the old L298N, it loses only about 0.5 V at 1 A, so your motors spin faster, your battery lasts longer and the board never gets hot enough to burn your fingers.
In this guide you'll see how the TB6612FNG works, how it compares with the L298N using real numbers, the 16 pins of the module and the STBY pin that trips up almost everyone at least once. Then we'll write, step by step, a first test sketch for the Arduino Uno, PWM speed control, a line follower mini robot with two TCRT5000 sensors, an ESP32 version with silent 20 kHz PWM and MicroPython code for the Raspberry Pi Pico.

What is the TB6612FNG and how does it work?
To reverse a DC motor you have to reverse the direction of the current flowing through it. An H-bridge made of four switches does exactly that: when two diagonal switches close, current flows through the motor one way; when the other two close, it flows the opposite way. In the TB6612FNG these switches are MOSFETs, and two separate bridges (channels A and B) sit on the same chip. Each channel has two direction inputs (AIN1/AIN2, BIN1/BIN2) and one speed input (PWMA, PWMB). The duty cycle of the PWM signal you apply to the speed input sets the average motor voltage and therefore its speed. The chip also has thermal shutdown, which turns the outputs off when it overheats, and undervoltage detection, which stops the circuit when the supply drops.
| Feature | Value | What it means in practice |
|---|---|---|
| Channels | 2 (A and B) | Two DC motors or one bipolar stepper |
| Motor voltage (VM) | 4.5–13.5 V (absolute max 15 V) | 4 AA batteries, a 2S Li-ion pack (7.4 V) or a 12 V adapter |
| Logic voltage (VCC) | 2.7–5.5 V | 5 V with the Uno, 3.3 V with the ESP32 and Pico |
| Continuous current | 1.2 A per channel | Enough for TT, N20 and small geared motors |
| Peak current | 3.2 A (single 10 ms pulse) | Handles the short current surge at start-up |
| Voltage drop | About 0.5 V at 1 A | Almost the full battery voltage reaches the motor |
| Max PWM frequency | 100 kHz | 20 kHz and above is silent to the ear |
| Standby current | Below 1 µA with STBY LOW | Near-zero draw while a battery robot is parked |
TB6612FNG vs L298N: voltage drop and heat
The bipolar transistors inside the L298N leave a saturation voltage across them even when fully on; since the current passes through both an upper and a lower transistor, the total drop at 1 A is about 2–3 V. The MOSFETs of the TB6612FNG behave like a small resistor instead: upper plus lower is about 0.5 Ω, so you lose 0.5 V at 1 A. Let's make it concrete: driving two motors that draw 1 A each from a 7.4 V 2S Li-ion pack, the L298N leaves about 5 V for the motor and turns 2.4 W per channel into heat, 4.8 W in total. With the TB6612FNG about 6.9 V reaches the motor and only 1 W of heat is produced across both channels. If you want to run the numbers yourself, see the electrical power calculation article.
| Feature | TB6612FNG | L298N | L9110S |
|---|---|---|---|
| Switch type | MOSFET | Bipolar transistor | Low-saturation transistor |
| Continuous current (per channel) | 1.2 A | 2 A (with heatsink) | About 0.8 A |
| Motor voltage | 4.5–13.5 V | 5–35 V | 2.5–12 V |
| Voltage drop at 1 A | About 0.5 V | About 2–3 V | About 1 V |
| Standby (sleep) pin | Yes (STBY) | No | No |
| 3.3 V logic | Fully compatible | Usually works | Fully compatible |
| Module size | About 20 x 20 mm | About 43 x 43 mm, with heatsink | About 29 x 23 mm |
So is the L298N useless? No: with motors running above 13.5 V or drawing more than 1.2 A continuous per channel, the TB6612FNG is out of its depth, and you need a heatsinked L298N or a bigger MOSFET driver such as the BTS7960. For a broad comparison of all drivers, have a look at the motor driver comparison. You can also connect the two channels in parallel (AIN1 with BIN1, AIN2 with BIN2, PWMA with PWMB, AO1 with BO1 and AO2 with BO2) to give a single motor up to 2.4 A continuous.
TB6612FNG pinout and wiring table
Common TB6612FNG modules (the SparkFun design and its clones) have 16 pins in two rows. One side carries power and motor outputs: VM motor supply, VCC logic supply, two GND pins, AO1/AO2 for motor A and BO1/BO2 for motor B. The other side has the control inputs: PWMA, AIN2, AIN1, STBY, BIN1, BIN2, PWMB and one GND. The module already has filter capacitors on VM and VCC; still, adding a 100 µF electrolytic capacitor on the motor supply reduces the voltage dip at start-up.
| TB6612FNG pin | Function | Arduino Uno | ESP32 | Raspberry Pi Pico |
|---|---|---|---|---|
| VM | Motor supply (4.5–13.5 V) | External battery (+) | External battery (+) | External battery (+) |
| VCC | Logic supply | 5V | 3V3 | 3V3(OUT), pin 36 |
| GND | Common ground | GND | GND | GND |
| STBY | Standby, HIGH = run | D4 | GPIO 23 | GP19 |
| PWMA | Channel A speed | D5 (PWM) | GPIO 25 | GP16 |
| AIN1 | Channel A direction 1 | D7 | GPIO 26 | GP17 |
| AIN2 | Channel A direction 2 | D8 | GPIO 27 | GP18 |
| PWMB | Channel B speed | D6 (PWM) | GPIO 33 | GP22 |
| BIN1 | Channel B direction 1 | D9 | GPIO 18 | GP20 |
| BIN2 | Channel B direction 2 | D10 | GPIO 19 | GP21 |
| AO1 / AO2 | Left motor leads | Motor A | Motor A | Motor A |
| BO1 / BO2 | Right motor leads | Motor B | Motor B | Motor B |
Truth table: forward, reverse, brake and coast
| IN1 | IN2 | PWM | STBY | Motor state |
|---|---|---|---|---|
| HIGH | LOW | HIGH | HIGH | Forward (clockwise) |
| LOW | HIGH | HIGH | HIGH | Reverse (counter-clockwise) |
| HIGH | LOW | LOW | HIGH | Short brake |
| LOW | HIGH | LOW | HIGH | Short brake |
| HIGH | HIGH | Any | HIGH | Short brake |
| LOW | LOW | HIGH | HIGH | Stop, outputs floating (coast) |
| Any | Any | Any | LOW | Standby: all outputs off |
The key detail in the table: when the PWM pin is LOW the motor is not released, it is braked. In every off phase of the PWM signal the motor terminals are shorted and the motor slows down on its own back EMF. This is called drive/brake mode, and it gives more linear, more stable speed control at low speeds. If you really want to let the motor freewheel, set IN1 and IN2 LOW together; the robot will then roll down a slope. When you need a sudden stop, set both direction inputs HIGH to apply a short brake and the robot stops within a few centimetres.
Step-by-step Arduino Uno wiring and first test
- Plug the module into a breadboard; connect the Uno's 5V pin to VCC and its GND to the module's GND.
- Connect the positive of the motor battery (e.g. 4 AA cells = 6 V or 2S Li-ion = 7.4 V) to VM and its negative to the module's GND. This GND must be on the same rail as the Uno's GND.
- Connect the left motor to AO1 and AO2 and the right motor to BO1 and BO2.
- Wire the control pins as in the table: STBY D4, PWMA D5, PWMB D6, AIN1 D7, AIN2 D8, BIN1 D9, BIN2 D10.
- Lift the wheels off the ground (put the robot on a box) and upload the test sketch below.
- Open the Serial Monitor at 9600 baud and check that the motors do what the printed step says.
- If a motor spins the wrong way, don't touch the code: just swap that motor's two wires (AO1 and AO2).
1// TB6612FNG ilk test: iki motor ileri, fren, geri, serbest dönüş, bekleme
2// TB6612FNG first test: both motors forward, brake, backward, coast, standby
3
4const int STBY = 4; // bekleme pini, HIGH = çalış / standby pin, HIGH = run
5const int PWMA = 5; // A kanalı hız (PWM) / channel A speed (PWM)
6const int AIN1 = 7; // A kanalı yön 1 / channel A direction 1
7const int AIN2 = 8; // A kanalı yön 2 / channel A direction 2
8const int PWMB = 6; // B kanalı hız (PWM) / channel B speed (PWM)
9const int BIN1 = 9; // B kanalı yön 1 / channel B direction 1
10const int BIN2 = 10; // B kanalı yön 2 / channel B direction 2
11
12// Bir motoru sür: hiz -255..255, eksi değer geri / drive one motor: speed -255..255, negative = reverse
13void motorSur(int in1, int in2, int pwm, int hiz) {
14 hiz = constrain(hiz, -255, 255);
15 if (hiz > 0) {
16 digitalWrite(in1, HIGH); digitalWrite(in2, LOW);
17 } else if (hiz < 0) {
18 digitalWrite(in1, LOW); digitalWrite(in2, HIGH);
19 } else {
20 // serbest dönüş: IN1 = IN2 = LOW, PWM = HIGH / coast: IN1 = IN2 = LOW, PWM = HIGH
21 digitalWrite(in1, LOW); digitalWrite(in2, LOW);
22 analogWrite(pwm, 255);
23 return;
24 }
25 analogWrite(pwm, abs(hiz));
26}
27
28// Kısa devre freni: iki yön girişi HIGH / short brake: both direction inputs HIGH
29void frenle(int in1, int in2, int pwm) {
30 digitalWrite(in1, HIGH); digitalWrite(in2, HIGH);
31 analogWrite(pwm, 255);
32}
33
34void setup() {
35 const int pinler[] = {STBY, PWMA, AIN1, AIN2, PWMB, BIN1, BIN2};
36 for (int p : pinler) pinMode(p, OUTPUT);
37 digitalWrite(STBY, HIGH); // sürücüyü uyandır / wake the driver up
38 Serial.begin(9600);
39}
40
41void loop() {
42 Serial.println("Ileri / Forward");
43 motorSur(AIN1, AIN2, PWMA, 180);
44 motorSur(BIN1, BIN2, PWMB, 180);
45 delay(2000);
46
47 Serial.println("Fren / Brake");
48 frenle(AIN1, AIN2, PWMA);
49 frenle(BIN1, BIN2, PWMB);
50 delay(1000);
51
52 Serial.println("Geri / Backward");
53 motorSur(AIN1, AIN2, PWMA, -180);
54 motorSur(BIN1, BIN2, PWMB, -180);
55 delay(2000);
56
57 Serial.println("Serbest donus / Coast");
58 motorSur(AIN1, AIN2, PWMA, 0);
59 motorSur(BIN1, BIN2, PWMB, 0);
60 delay(1000);
61
62 Serial.println("Bekleme / Standby");
63 digitalWrite(STBY, LOW); // tüm çıkışlar kapalı / all outputs off
64 delay(2000);
65 digitalWrite(STBY, HIGH);
66}
67| Code part | What it does |
|---|---|
| digitalWrite(STBY, HIGH) | Takes the driver out of standby; without this line no motor turns |
| motorSur(in1, in2, pwm, hiz) | Takes a speed from -255 to 255; the sign sets the direction, the absolute value the PWM duty |
| constrain(hiz, -255, 255) | Prevents out-of-range values from reaching analogWrite |
| frenle() | Applies a short brake by setting both direction inputs HIGH |
| hiz = 0 | IN1 and IN2 LOW, PWM HIGH: the motor coasts |
| digitalWrite(STBY, LOW) | Turns all outputs off; the driver draws less than 1 µA |
PWM speed control: frequency, dead zone and soft start
On the Uno, analogWrite() takes a value from 0 to 255; the PWM frequency is about 980 Hz on D5 and D6, and 490 Hz on D3, D9, D10 and D11. These frequencies are in the audible range, which is why the motor whines at low speed. Since the TB6612FNG accepts PWM up to 100 kHz, on the ESP32 and Pico you can raise the frequency to 20 kHz and get rid of the noise completely. On the Uno you can also move the PWM lines to D9 and D10 and put TCCR1B = (TCCR1B & 0b11111000) | 0x01; in setup() to run Timer1 at about 31 kHz; just remember that the Servo library also uses Timer1, so you can't drive a servo at the same time.
The second important point is the dead zone. Geared motors need a certain voltage to overcome friction; most TT motors at 6 V don't turn at all below a PWM value of 60–90, they just hum. To find this threshold, start the value 180 in the test sketch at 40 and raise it in steps of 10; the value where the wheel starts turning is your limit, and it rises as the battery gets weaker. Start your speed commands from there. The third point is the ramp: jumping from 0 to 255 at once pushes the start-up current to its peak, the battery voltage sags and the board may reset. Raising the speed by a few steps every 10 ms solves this; you'll see how in the ESP32 code.
Mini robot and line follower code
The TB6612FNG is most at home in two-wheeled mini robots. The sketch below is a simple line follower with two TCRT5000 modules placed on either side of a black line. The digital outputs of the sensor modules go to A0 (left) and A1 (right); these modules usually output HIGH over black and LOW over white. If both see white, the line is in the middle and the robot drives straight. If the left sensor touches the line, the robot has drifted right and must turn left; the opposite applies to the right sensor. Spinning the inner wheel slightly backwards in a turn helps you not miss sharp bends.
1// TB6612FNG + 2 TCRT5000 ile çizgi izleyen mini robot (Arduino Uno)
2// Line follower mini robot with TB6612FNG + 2 TCRT5000 (Arduino Uno)
3
4const int STBY = 4;
5const int PWMA = 5, AIN1 = 7, AIN2 = 8; // A = sol motor / left motor
6const int PWMB = 6, BIN1 = 9, BIN2 = 10; // B = sağ motor / right motor
7const int SOL_SENSOR = A0; // sol TCRT5000 DO / left TCRT5000 DO
8const int SAG_SENSOR = A1; // sağ TCRT5000 DO / right TCRT5000 DO
9const int SIYAH = HIGH; // modülün siyahta verdiği değer / value the module gives on black
10
11const int HIZ = 150; // düz giderken iki teker / both wheels going straight
12const int DIS_TEKER = 170; // virajda dış teker / outer wheel in a turn
13const int IC_TEKER = -60; // virajda iç teker hafif geri / inner wheel slightly backward
14
15void motorSur(int in1, int in2, int pwm, int hiz) {
16 hiz = constrain(hiz, -255, 255);
17 digitalWrite(in1, hiz > 0 ? HIGH : LOW);
18 digitalWrite(in2, hiz < 0 ? HIGH : LOW);
19 analogWrite(pwm, hiz == 0 ? 255 : abs(hiz)); // 0 = serbest dönüş / 0 = coast
20}
21
22// sol ve sağ tekeri birlikte sür / drive left and right wheels together
23void surus(int sol, int sag) {
24 motorSur(AIN1, AIN2, PWMA, sol);
25 motorSur(BIN1, BIN2, PWMB, sag);
26}
27
28void setup() {
29 const int cikislar[] = {STBY, PWMA, AIN1, AIN2, PWMB, BIN1, BIN2};
30 for (int p : cikislar) pinMode(p, OUTPUT);
31 pinMode(SOL_SENSOR, INPUT);
32 pinMode(SAG_SENSOR, INPUT);
33 digitalWrite(STBY, HIGH);
34 delay(1000); // robotu çizgiye koymak için süre / time to place the robot on the line
35}
36
37void loop() {
38 bool solSiyah = digitalRead(SOL_SENSOR) == SIYAH;
39 bool sagSiyah = digitalRead(SAG_SENSOR) == SIYAH;
40
41 if (!solSiyah && !sagSiyah) {
42 surus(HIZ, HIZ); // çizgi ortada: düz git / line in the middle: go straight
43 } else if (solSiyah && !sagSiyah) {
44 surus(IC_TEKER, DIS_TEKER); // çizgi solda: sola dön / line on the left: turn left
45 } else if (!solSiyah && sagSiyah) {
46 surus(DIS_TEKER, IC_TEKER); // çizgi sağda: sağa dön / line on the right: turn right
47 } else {
48 surus(HIZ, HIZ); // ikisi de siyah: kavşak, düz geç / both black: junction, go straight
49 }
50}
51If the robot loses the line in bends, first lower HIZ, then make IC_TEKER more negative. When you go up to three or five sensors and add PID control, the robot runs much smoother and faster; the details are in the line follower robot guide. With the same motorSur() function you can also build an obstacle avoiding robot or a sumo robot.
TB6612FNG with ESP32: 3.3 V compatibility and 20 kHz PWM
The TB6612FNG inputs treat about 70% of VCC as HIGH. When you power VCC from the ESP32's 3V3 pin, that threshold is about 2.3 V and the ESP32's 3.3 V outputs are comfortably HIGH, so no level shifter is needed. If you connect VCC to 5 V the threshold rises to 3.5 V and a 3.3 V signal is no longer reliable, so VCC must go to 3V3. VM still comes from the external battery. On the ESP32 we use the LEDC hardware instead of analogWrite: 20 kHz and 8-bit (0–255) resolution give speed control that is silent and on the same scale as the Uno code. The sketch compiles on both 2.x and 3.x of the ESP32 Arduino core; in 3.x, ledcAttach() works directly with the pin number instead of a channel number. From the Serial Monitor you can drive the robot with the w, s, a, d and x keys and change the speed with + and -; speed changes are smoothed by a ramp. GPIO 34–39 are input only, so don't connect them to the driver. You can reuse the same drive functions in the Wi-Fi controlled robot car or the PS4 controller car projects.
1// ESP32 + TB6612FNG: 20 kHz sessiz PWM, rampa ve Seri Monitör komutları
2// ESP32 + TB6612FNG: silent 20 kHz PWM, ramp and Serial Monitor commands
3// Komutlar / commands: w ileri/forward, s geri/back, a sol/left, d sağ/right, x fren/brake, + -
4
5const int STBY = 23;
6const int PWMA = 25, AIN1 = 26, AIN2 = 27; // sol motor / left motor
7const int PWMB = 33, BIN1 = 18, BIN2 = 19; // sağ motor / right motor
8
9const int PWM_FREKANS = 20000; // 20 kHz: kulak duymaz / inaudible
10const int PWM_COZUNURLUK = 8; // 8 bit: 0-255
11const int KANAL_A = 0, KANAL_B = 1; // yalnız çekirdek 2.x / core 2.x only
12const int RAMPA_ADIM = 8; // her 10 ms'de en fazla değişim / max change every 10 ms
13
14int hiz = 160; // komut hızı / command speed
15int hedefSol = 0, hedefSag = 0; // hedef hızlar / target speeds
16int anlikSol = 0, anlikSag = 0; // o anki hızlar / current speeds
17unsigned long sonRampa = 0;
18
19void pwmHazirla() {
20#if ESP_ARDUINO_VERSION_MAJOR >= 3
21 ledcAttach(PWMA, PWM_FREKANS, PWM_COZUNURLUK); // 3.x: pin tabanlı / pin based
22 ledcAttach(PWMB, PWM_FREKANS, PWM_COZUNURLUK);
23#else
24 ledcSetup(KANAL_A, PWM_FREKANS, PWM_COZUNURLUK); // 2.x: kanal tabanlı / channel based
25 ledcSetup(KANAL_B, PWM_FREKANS, PWM_COZUNURLUK);
26 ledcAttachPin(PWMA, KANAL_A);
27 ledcAttachPin(PWMB, KANAL_B);
28#endif
29}
30
31void pwmYaz(int pin, int kanal, int deger) {
32#if ESP_ARDUINO_VERSION_MAJOR >= 3
33 (void)kanal;
34 ledcWrite(pin, deger);
35#else
36 (void)pin;
37 ledcWrite(kanal, deger);
38#endif
39}
40
41void motorSur(int in1, int in2, int pin, int kanal, int deger) {
42 deger = constrain(deger, -255, 255);
43 digitalWrite(in1, deger > 0 ? HIGH : LOW);
44 digitalWrite(in2, deger < 0 ? HIGH : LOW);
45 pwmYaz(pin, kanal, deger == 0 ? 255 : abs(deger)); // 0 = serbest dönüş / 0 = coast
46}
47
48void frenle() {
49 hedefSol = hedefSag = anlikSol = anlikSag = 0;
50 digitalWrite(AIN1, HIGH); digitalWrite(AIN2, HIGH);
51 digitalWrite(BIN1, HIGH); digitalWrite(BIN2, HIGH);
52}
53
54// anlık değeri hedefe adım adım yaklaştır / move the current value toward the target step by step
55int yaklas(int anlik, int hedef) {
56 if (anlik < hedef) return min(anlik + RAMPA_ADIM, hedef);
57 if (anlik > hedef) return max(anlik - RAMPA_ADIM, hedef);
58 return anlik;
59}
60
61void setup() {
62 Serial.begin(115200);
63 const int cikislar[] = {STBY, AIN1, AIN2, BIN1, BIN2};
64 for (int p : cikislar) pinMode(p, OUTPUT);
65 pwmHazirla();
66 digitalWrite(STBY, HIGH);
67 Serial.println("w/s/a/d/x ve +/- / w/s/a/d/x and +/-");
68}
69
70void loop() {
71 if (Serial.available()) {
72 char k = Serial.read();
73 bool frenKomutu = false;
74 switch (k) {
75 case 'w': hedefSol = hiz; hedefSag = hiz; break;
76 case 's': hedefSol = -hiz; hedefSag = -hiz; break;
77 case 'a': hedefSol = -hiz / 2; hedefSag = hiz / 2; break; // yerinde sola / spin left
78 case 'd': hedefSol = hiz / 2; hedefSag = -hiz / 2; break; // yerinde sağa / spin right
79 case 'x': frenle(); frenKomutu = true; break;
80 case '+': hiz = min(hiz + 20, 255); break;
81 case '-': hiz = max(hiz - 20, 60); break; // 60 altı ölü bölge / below 60 = dead zone
82 default: return;
83 }
84 Serial.printf("komut / command: %c hiz / speed: %d\n", k, hiz);
85 if (frenKomutu) return;
86 }
87
88 if (millis() - sonRampa >= 10) { // 10 ms'de bir rampa adımı / one ramp step every 10 ms
89 sonRampa = millis();
90 if (anlikSol != hedefSol || anlikSag != hedefSag) {
91 anlikSol = yaklas(anlikSol, hedefSol);
92 anlikSag = yaklas(anlikSag, hedefSag);
93 motorSur(AIN1, AIN2, PWMA, KANAL_A, anlikSol);
94 motorSur(BIN1, BIN2, PWMB, KANAL_B, anlikSag);
95 }
96 }
97}
98TB6612FNG with Raspberry Pi Pico (MicroPython)
The Raspberry Pi Pico also uses 3.3 V logic and every GPIO can generate PWM. In MicroPython you set the frequency of a PWM object with freq() and the duty cycle from 0 to 65535 with duty_u16(). In the code below the speed is given as a percentage (-100 to 100). GP16 and GP22 are on different PWM slices, so the two channels don't affect each other; two pins on the same slice (e.g. GP16 and GP17) share one frequency, so keep this in mind when choosing pins. Connect the module's VCC to the Pico's 3V3(OUT) pin and feed the motor battery to the module's VM pin, not to the Pico's VSYS.
1# Raspberry Pi Pico + TB6612FNG (MicroPython): ileri, fren, geri, yerinde dönüş
2# Raspberry Pi Pico + TB6612FNG (MicroPython): forward, brake, backward, spin
3from machine import Pin, PWM
4import time
5
6STBY = Pin(19, Pin.OUT)
7AIN1, AIN2 = Pin(17, Pin.OUT), Pin(18, Pin.OUT) # sol motor / left motor
8BIN1, BIN2 = Pin(20, Pin.OUT), Pin(21, Pin.OUT) # sağ motor / right motor
9PWMA, PWMB = PWM(Pin(16)), PWM(Pin(22))
10for p in (PWMA, PWMB):
11 p.freq(20000) # 20 kHz: sessiz / silent
12
13
14def motor(in1, in2, pwm, hiz):
15 # hiz -100..100 yüzde, eksi değer geri / speed -100..100 percent, negative = reverse
16 hiz = max(-100, min(100, hiz))
17 in1.value(1 if hiz > 0 else 0)
18 in2.value(1 if hiz < 0 else 0)
19 if hiz == 0:
20 pwm.duty_u16(65535) # serbest dönüş / coast
21 else:
22 pwm.duty_u16(abs(hiz) * 65535 // 100)
23
24
25def surus(sol, sag):
26 motor(AIN1, AIN2, PWMA, sol)
27 motor(BIN1, BIN2, PWMB, sag)
28
29
30def fren():
31 for p in (AIN1, AIN2, BIN1, BIN2):
32 p.value(1) # kısa devre freni / short brake
33
34
35STBY.value(1)
36try:
37 while True:
38 surus(60, 60) # ileri / forward
39 time.sleep(2)
40 fren()
41 time.sleep(0.5)
42 surus(-60, -60) # geri / backward
43 time.sleep(2)
44 surus(50, -50) # yerinde sağa / spin right
45 time.sleep(1)
46 surus(0, 0) # serbest / coast
47 time.sleep(1)
48finally:
49 surus(0, 0)
50 STBY.value(0) # bekleme modu / standby
51TB6612FNG project ideas
- Racing line follower: N20 motors, five sensors and PID; the low loss of the TB6612FNG makes a clear difference in speed (line follower robot).
- Bluetooth robot car: control from your phone with an HC-05; swap the L298N design for a TB6612FNG and the car goes faster on the same battery (Arduino robot car).
- Obstacle avoiding robot: measure distance with an HC-SR04, stop with a short brake and turn when an obstacle is closer than 20 cm (obstacle avoiding robot).
- Self-balancing robot: stay upright on two wheels with an MPU6050 and a fast-reacting MOSFET driver (self-balancing robot).
- Reversible pump or curtain motor: small motors that must change direction draw almost no current in standby thanks to STBY.
Common mistakes and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| No motor turns | STBY floating or LOW | Set STBY HIGH or tie it to VCC |
| Motors jitter, Arduino resets | Motors powered from the Arduino's 5V or no common GND | Power VM from a separate battery, join the grounds, add 100 µF on VM |
| One motor spins backwards | Motor wires reversed | Swap AO1 and AO2 (or BO1 and BO2) |
| Motor hums at low speed but doesn't turn | PWM value below the dead zone | Start the lowest speed around 60–90 |
| Module gets very hot, motor stops | Continuous current above 1.2 A, thermal shutdown active | Use a smaller motor, parallel the channels or pick a stronger driver |
| Module died around 12 V | 15 V absolute max on VM exceeded; with 3S Li-ion (12.6 V fully charged) motor spikes eat up the margin | Use at most 2S Li-ion or a regulated 12 V adapter |
| High-pitched noise from the motor | The Uno's 490/980 Hz PWM | Use 20 kHz on ESP32/Pico or set Timer1 to 31 kHz on the Uno |
If you want to try the TB6612FNG in a real project, the BlueGrays app has the obstacle avoiding robot, TCRT5000 floor detection and PWM speed control projects with step-by-step circuit diagrams and code; you can easily convert their L298N wiring to the TB6612FNG with the pin table in this article.
Frequently asked questions
How many amps can the TB6612FNG handle?
It delivers 1.2 A continuous (average) per channel and 3.2 A peak in short pulses. If you connect both channels in parallel, a single motor can get up to 2.4 A continuous. Above these values the chip heats up and thermal shutdown turns the outputs off.
Is the TB6612FNG better than the L298N?
For motors below 13.5 V that draw less than 1.2 A per channel, yes: the TB6612FNG loses about 0.5 V at 1 A, while the L298N loses 2–3 V and gets hot. For higher voltage or higher current motors you need a heatsinked L298N or a bigger MOSFET driver.
What does the STBY pin do on the TB6612FNG?
STBY puts the driver into standby. When it is LOW all outputs turn off and the chip draws less than 1 µA; when it is HIGH the driver runs. Because of the internal pull-down, the motors won't turn if it is left floating, so it must go to a pin or to VCC.
Does the TB6612FNG work with 3.3 V?
Yes. The logic supply (VCC) ranges from 2.7 to 5.5 V and the HIGH threshold is about 70% of VCC. If you power VCC from the board's 3.3 V pin, an ESP32 or Raspberry Pi Pico connects directly without a level shifter; the motor supply goes separately to VM.
Can the TB6612FNG drive a stepper motor?
Yes, its two channels can drive the two coils of a bipolar stepper and it works with the Arduino Stepper library. However, it has no current limiting or microstepping, so an A4988 or TMC2209 is a much better fit for motors like the NEMA 17.
What battery should I use with the TB6612FNG?
The motor supply must be between 4.5 and 13.5 V. For robots with TT or N20 motors, 4 AA batteries (6 V) or a 2S Li-ion pack (7.4 V, 8.4 V fully charged) are the most common choices. The logic supply comes separately from the board's 5 V or 3.3 V pin.
Projects to build after reading this
See all projects
HC-SR04 Distance Measurement (Serial Display)
The HC-SR04 sensor works just like a bat finding its way in the dark: it sends out a sound you cannot hear, listens for the echo and measures how far away the object in front of it is.

ESP32 LED Fade with PWM
Smoothly changing the brightness of the LED from 0 to max, from max to 0. We control PWM with analogWrite() as in Arduino - the same syntax as ESP32 Arduino Core 3.0+ works without problems. Pin definition + pinMode + analogWrite is enough.

ESP32 LED Brightness Control with a Potentiometer (Analog → PWM)
In this project, we control the brightness of an LED analogically using a potentiometer. The ESP32's ADC pin reads the 0-3.3V voltage from the potentiometer, and this value is then converted into a PWM (Pulse Width Modulation) signal and sent to the LED. As a result, as you turn the potentiometer, the LED gradually brightens and dims. With Arduino Core 3.0+, analogWrite() can be used directly; on the ESP32-S2/S3, the ADC resolution is fixed at 12-bit.

Reading Reflection (Proximity) with TCRT5000
With a small sensor that sends out invisible light and measures how much bounces back, you can detect the surface in front of it.

TCRT5000 Black and White Surface Detection
With the little sensor that acts as the eye of line-following robots, you can tell whether the floor is black or white.

Bluetooth Controlled Car with L298N
Turn your phone into a remote and drive your own robot car. The Arduino receives commands from a remote-control app on your phone through a Bluetooth module and spins the wheels with a motor driver…

Obstacle Avoidance Robot
How about building a smart vehicle that finds its own way? The Obstacle Avoidance Robot constantly scans its surroundings thanks to the ultrasonic sensor in front of it.

Raspberry Pi Pico PWM LED Fade (Breathing Effect)
The LED doesn't just blink anymore, it breathes! With the Raspberry Pi Pico's PWM (Pulse Width Modulation), the LED's brightness slowly rises and then slowly fades, a calm "breathing" effect like a sleeping laptop's light. You'll learn the machine.PWM class, the 16-bit brightness value from 0–65535 with duty_u16() and the PWM frequency.
More articles
BlueGrays app
Build this circuit step by step on your phone
Wiring diagram, code and parts list on one screen. 500+ Arduino, ESP32, ESP8266, Pico, mBot and micro:bit projects ready to build.
Scan with your phone
Point your camera at the code and your phone's app store opens.
or open the store

