MyRoboPathOpen Robotics Lab
robotics basics18 min readUpdated 2026-03-14Beginner

Robot Motion: DC Motors, Driver Wiring (L298N vs TB6612 vs DRV8833) & Locomotion

Master robot propulsion: H-Bridge principles, hands-on wiring for L298N, TB6612FNG, and DRV8833 drivers, PWM speed control, and comparison of Differential, 4WD Skid, Tracked, and Omni locomotion.

MyRoboPath Engineering Lab
Peer-Reviewed Open-Source Hardware & Firmware Guide

Key Engineering Takeaways

  • An H-Bridge circuit uses 4 electronic switches (MOSFETs/BJTs) to reverse polarity across a DC motor, enabling Forward, Reverse, and Brake.
  • The legacy L298N uses bipolar transistors which waste 1.5V–2.5V as heat; modern MOSFET drivers (TB6612FNG, DRV8833) run cool and deliver 95%+ battery efficiency.
  • PWM (Pulse Width Modulation) duty cycle controls motor speed without sacrificing torque.
  • Differential drive (2 powered wheels + 1 passive caster) is the most agile, turning in-place on its own central axis.
  • Always add flyback diode protection and 100nF ceramic decoupling capacitors across motor terminals to eliminate high-frequency inductive electrical noise.
Prerequisites
  • Basic digital I/O and PWM concepts
Required Hardware / Tools
  • 2x TT Yellow DC Gearmotors
  • L298N or TB6612FNG Motor Driver
  • 2S Li-ion Battery or 4xAA Battery Holder
  • Arduino Uno/Nano
  • Jumper Wires

The H-Bridge: Bidirectional DC Motor Control

A direct-current (DC) motor spins forward when current flows in one direction, and reverses when current is flipped. To achieve this electronically without mechanical switches, robotics uses an H-Bridge:

text snippet
text
         + V_BAT (Battery Positive)
             │                │
          [ Q1 ]            [ Q2 ]
             │──[ Motor M ]───│
          [ Q3 ]            [ Q4 ]
             │                │
            GND              GND

• Forward Drive:  Q1 & Q4 closed -> Current flows LEFT to RIGHT
• Reverse Drive:  Q2 & Q3 closed -> Current flows RIGHT to LEFT
• Active Brake:   Q3 & Q4 closed (or Q1 & Q2) -> Shorts motor terminals
• Coast/Freewheel: All switches open -> Motor spins down freely

By pulsing the gate signals using PWM (Pulse Width Modulation) at frequencies from 1kHz to 20kHz, we precisely modulate the average voltage and rotational speed.

H-bridge internal diagram and motor driver wiring
Figure 4.1: Internal H-Bridge architecture and wiring pinouts for L298N and TB6612FNG dual motor drivers.Visual Guide

Comparing Drivers: L298N vs TB6612FNG vs DRV8833

Motor Driver Comparison Table:

Spec / FeatureL298N Dual H-BridgeTB6612FNG Dual DriverDRV8833 Dual Driver
Switch TechnologyBJT (Bipolar Transistors)Power MOSFETsPower MOSFETs
Internal Voltage Drop1.8V to 3.2V (High heat loss)< 0.3V (Very efficient)< 0.2V (Very efficient)
Motor Operating Voltage5V – 35V4.5V – 15V2.7V – 10.8V
Continuous Current / Ch2.0A1.2A (3.2A peak)1.5A (2.5A peak)
Logic Level Voltage5V only2.7V – 5.5V (ESP32/3.3V safe)2.0V – 5.5V (ESP32/3.3V safe)
Built-in 5V RegulatorYes (78M05 onboard)No (Requires external 5V/3.3V)No
Physical SizeHuge (Heavy heatsink)Tiny (Breakout postage stamp)Ultra-compact
RecommendationLegacy hobby kitsTop pick for 2S/3S roversTop pick for low-voltage (3V-6V)

Hands-On Wiring: Dual Motor Driver to Arduino

TB6612FNG / L298N Pin Connections:

  • VM / VMS: Connect to Battery Positive (+7.4V from 2S 18650 pack).
  • GND: Connect to Battery Negative AND Arduino GND pin.
  • VCC: Connect to Arduino 5V pin (Logic power).
  • STBY (Standby): Connect to 5V (or high GPIO) to activate driver.
  • PWMA / PWMB: Connect to Arduino PWM pins (e.g. Pin 5 and Pin 6).
  • AIN1 / AIN2 (Left Motor): Connect to Arduino digital pins (e.g. Pin 7 and Pin 8).
  • BIN1 / BIN2 (Right Motor): Connect to Arduino digital pins (e.g. Pin 9 and Pin 10).
  • MOTOR A / MOTOR B Terminals: Connect to Left and Right DC gearmotors.

Production Motor Control Code (Forward, Turn, Stop)

firmware.ino
cpp
// Pin Assignments for Left and Right Motors
const int ENA = 5;  // Left Motor Speed (PWM)
const int IN1 = 7;  // Left Motor Direction A
const int IN2 = 8;  // Left Motor Direction B

const int ENB = 6;  // Right Motor Speed (PWM)
const int IN3 = 9;  // Right Motor Direction A
const int IN4 = 10; // Right Motor Direction B

void setup() {
  pinMode(ENA, OUTPUT);
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  
  pinMode(ENB, OUTPUT);
  pinMode(IN3, OUTPUT);
  pinMode(IN4, OUTPUT);
}

void setMotors(int leftSpeed, int rightSpeed) {
  // Left Motor Direction & Speed
  if (leftSpeed >= 0) {
    digitalWrite(IN1, HIGH);
    digitalWrite(IN2, LOW);
    analogWrite(ENA, constrain(leftSpeed, 0, 255));
  } else {
    digitalWrite(IN1, LOW);
    digitalWrite(IN2, HIGH);
    analogWrite(ENA, constrain(-leftSpeed, 0, 255));
  }

  // Right Motor Direction & Speed
  if (rightSpeed >= 0) {
    digitalWrite(IN3, HIGH);
    digitalWrite(IN4, LOW);
    analogWrite(ENB, constrain(rightSpeed, 0, 255));
  } else {
    digitalWrite(IN3, LOW);
    digitalWrite(IN4, HIGH);
    analogWrite(ENB, constrain(-rightSpeed, 0, 255));
  }
}

void brake() {
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, LOW);
  analogWrite(ENA, 0);
  analogWrite(ENB, 0);
}

void loop() {
  setMotors(200, 200);   // Move Forward at ~80% speed
  delay(2000);

  setMotors(-180, 180);  // Spin Turn Left on the spot
  delay(800);

  setMotors(200, 200);   // Move Forward
  delay(2000);

  brake();               // Active Stop
  delay(3000);
}

Locomotion Architectures: 2WD vs 4WD vs Tracks vs Omni

1. Differential Drive (2 Drive Wheels + 1 Caster)

  • Mechanics: Simplest design. Turning in place achieved by spinning wheels in opposite directions.
  • Best For: Flat floors, indoor navigation, line following, maze solving.

2. 4WD Skid Steer

  • Mechanics: 4 fixed drive wheels. Turning requires skidding wheels sideways across the ground.
  • Pros/Cons: High traction on carpet and dirt; higher tire friction and battery drain during sharp turns.

3. Tracked / Continuous Treads

  • Mechanics: Rubber tank treads distribute vehicle weight over large surface area.
  • Best For: Rough outdoor terrain, gravel, grass, and climbing over obstacles.

4. Omni-Directional / Mecanum Wheels

  • Mechanics: 4 wheels with 45° angled passive rollers allow translation in any vector (strafe left/right, diagonal) without changing heading.
  • Best For: Advanced robotics competitions (FTC/FRC), warehouse AGVs, confined indoor mapping.

Frequently Asked Questions

Why does one motor spin faster than the other, making my robot veer to one side?

Cheap hobby DC gearmotors have manufacturing tolerances of ±10% to 15% in magnetic strength, internal friction, and coil windings. Compensate for this in software by multiplying the faster motor PWM by a trim multiplier (e.g. leftSpeed * 0.92) or upgrade to motors with optical/magnetic wheel encoders for closed-loop PID speed synchronization.

Why do my motors emit a high-pitched whining noise at low PWM values?

Standard Arduino PWM frequency is ~490Hz or 980Hz, which sits directly in the audible human hearing range. When the duty cycle is too low to overcome static motor gearbox friction (stiction), the coils vibrate at that frequency without spinning. Set your minimum PWM to at least 70–90 or increase timer PWM frequencies.

Tags:#DC Motors#Motor Drivers#L298N#TB6612FNG#DRV8833#PWM Speed Control#Locomotion