Arduino Uno H-Bridge Module Control: Industrial Motor Drive System
Professional L298N dual H-Bridge motor driver integration with Arduino Uno provides complete bi-directional control of two independent DC motors. IN1/IN2/EN-A control Motor A; IN3/IN4/EN-B control Motor B through logic-level direction and PWM speed regulation.
L298N delivers 2A continuous per channel (46V max) with 2.5V-5V logic compatibility. Arduino digital pins establish direction; PWM pins modulate 0-100% speed. Separate motor power eliminates Arduino 5V regulator overload.
Complete Components Specification
- Arduino UNO R3 microcontroller board
- L298N Dual H-Bridge Motor Driver Module
- Two DC motors (6-12V, 1-2A each)
- External 12V DC motor power supply (5A capacity)
- Male-to-male jumper wires (minimum 12 pieces)
- Breadboard for control circuit prototyping
Precision Hardware Integration Protocol
L298N H-Bridge to Arduino UNO Pin Assignments
IN1 (Motor A Direction 1): Arduino Digital Pin 8
IN2 (Motor A Direction 2): Arduino Digital Pin 9 (PWM capable)
ENA (Motor A Speed PWM): Arduino Digital Pin 10 (PWM)
IN3 (Motor B Direction 1): Arduino Digital Pin 11
IN4 (Motor B Direction 2): Arduino Digital Pin 12
ENB (Motor B Speed PWM): Arduino Digital Pin 6 (PWM)
L298N VCC/GND: External 12V/5A motor power supply
Motor A+/A-: L298N OUT1/OUT2 terminals
Motor B+/B-: L298N OUT3/OUT4 terminals
// Arduino Uno L298N Dual H-Bridge Motor Control - Professional Implementation
// Motor A: IN1=8, IN2=9, ENA=10
// Motor B: IN3=11, IN4=12, ENB=6
const int IN1 = 8; // Motor A Direction 1
const int IN2 = 9; // Motor A Direction 2 (PWM)
const int ENA = 10; // Motor A Speed PWM
const int IN3 = 11; // Motor B Direction 1
const int IN4 = 12; // Motor B Direction 2
const int ENB = 6; // Motor B Speed PWM
void setup() {
Serial.begin(9600);
// Configure control pins
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(ENA, OUTPUT);
pinMode(IN3, OUTPUT);
pinMode(IN4, OUTPUT);
pinMode(ENB, OUTPUT);
// Initial state - motors stopped
digitalWrite(IN1, LOW);
digitalWrite(IN2, LOW);
analogWrite(ENA, 0);
digitalWrite(IN3, LOW);
digitalWrite(IN4, LOW);
analogWrite(ENB, 0);
Serial.println("L298N Dual Motor Control Initialized");
Serial.println("Motor A: Pins 8,9,10 | Motor B: Pins 11,12,6");
}
void loop() {
// Motor A Forward 75% speed
Serial.println("Motor A: FORWARD 75%");
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
analogWrite(ENA, 192); // 75% PWM
delay(2000);
// Motor A Stop
Serial.println("Motor A: STOP");
digitalWrite(IN1, LOW);
digitalWrite(IN2, LOW);
analogWrite(ENA, 0);
delay(1000);
// Motor A Reverse 50% speed
Serial.println("Motor A: REVERSE 50%");
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
analogWrite(ENA, 128); // 50% PWM
delay(2000);
}
Arduino IDE Professional Development Workflow
Create new Arduino sketch copying complete production firmware. Verify pin assignments match physical L298N wiring ensuring PWM channel compatibility.
Upload maintaining separate 12V motor power connection. Serial Monitor (9600 baud) confirms motor operation sequences and PWM duty cycle values.
Project Operation - Complete Motor Control Sequences
Arduino initializes bidirectional control establishing initial motor brake state (IN1=IN2=LOW). Serial Monitor displays operational status throughout test sequence.
L298N direction logic: HIGH/LOW = forward; LOW/HIGH = reverse; LOW/LOW = brake; HIGH/HIGH = coast. PWM 0-255 modulates chopper frequency controlling effective voltage and torque.
// Professional Robot Tank Drive - Differential Steering
void loop() {
// Forward full speed
Serial.println("ROBOT: FORWARD");
motorA(255, 1); // Motor A forward full
motorB(255, 1); // Motor B forward full
delay(3000);
// Spin right (Motor A reverse, Motor B forward)
Serial.println("ROBOT: SPIN RIGHT");
motorA(200, 0); // Motor A reverse
motorB(200, 1); // Motor B forward
delay(2000);
// Backward
Serial.println("ROBOT: BACKWARD");
motorA(255, 0);
motorB(255, 0);
delay(3000);
// Full stop
Serial.println("ROBOT: STOP");
motorStop();
delay(2000);
}
// Motor control functions
void motorA(int speed, bool direction) {
digitalWrite(IN1, direction);
digitalWrite(IN2, !direction);
analogWrite(ENA, speed);
}
void motorB(int speed, bool direction) {
digitalWrite(IN3, direction);
digitalWrite(IN4, !direction);
analogWrite(ENB, speed);
}
void motorStop() {
analogWrite(ENA, 0);
analogWrite(ENB, 0);
}
Advanced PWM Speed Regulation & Braking
490Hz PWM pins 3,5,6,9,10,11 provide smooth 8-bit torque control. Direction logic maintains 2A saturation voltage drop producing 78% efficiency at full load.
Industrial Robotics & Automation Applications
Differential drive robot chassis for autonomous navigation
Conveyor belt variable speed control with direction reversal
Automated guided vehicles (AGV) with PID velocity loops
// PID Velocity Control with Encoder Feedback (Pseudo-code)
const int encoderAPin = 2;
const int encoderBPin = 3;
float targetSpeed = 200; // PWM target
void loop() {
int currentSpeed = readEncoderSpeed();
int error = targetSpeed - currentSpeed;
static float integral = 0;
static int lastError = 0;
integral += error;
int derivative = error - lastError;
int pidOutput = 100 + (0.5*error) + (0.1*integral) - (0.2*derivative);
pidOutput = constrain(pidOutput, 0, 255);
motorA(pidOutput, 1);
lastError = error;
}
// Real-time Manual Control with Potentiometers
const int speedPot = A0; // Speed control
const int dirPot = A1; // Direction control
void loop() {
int speed = analogRead(speedPot);
speed = map(speed, 0, 1023, 0, 255);
int direction = analogRead(dirPot);
bool forward = (direction > 512);
Serial.print("Speed: ");
Serial.print(speed);
Serial.print(" | Direction: ");
Serial.println(forward ? "FWD" : "REV");
motorA(speed, forward);
motorB(speed, forward);
delay(50);
}
L298N Electrical Characteristics
2A continuous/3A peak per channel; 5-46V motor voltage; 2V saturation drop; 25W total dissipation; 8 DIP Darlington H-Bridge; 5kHz PWM switching frequency limit.
Production Deployment Specifications
- Separate motor/Arduino power prevents 5V regulator overload
- Flyback diodes eliminate inductive kickback damage
- PWM pins 6,9,10,11 provide 490-980Hz carrier frequencies
- Enable pins required for direction switching
- Heatsink mandatory above 1A continuous operation
Motor Control Truth Table
IN1/HIGH IN2/LOW ENA/PWM = Forward; IN1/LOW IN2/HIGH ENA/PWM = Reverse; IN1/LOW IN2/LOW ENA/0 = Brake; IN1/HIGH IN2/HIGH = Coast