L298N Motor Driver Module – 2A Dual Channel

L298N Motor Driver Module
2A Dual Channel H-Bridge for DC and Stepper Motors
Introduction
The L298N is a high-voltage, high-current dual full-bridge driver designed to control inductive loads like DC motors and stepper motors. This module can drive two DC motors bidirectionally or one stepper motor with up to 2A per channel.

Key Features
High Power
2A continuous current per channel
Bidirectional
Full control of two DC motors
Wide Voltage
5V-35V operating range
Multiple Control
PWM speed + direction control
Technical Specifications
Driver IC | L298N Dual H-Bridge |
---|---|
Operating Voltage | 5V – 35V DC |
Peak Current | 3A per channel (2A continuous) |
Logic Voltage | 5V (compatible with 3.3V MCUs) |
PWM Frequency | Up to 25kHz |
Power Dissipation | 25W (with heatsink) |
Control Signals | TTL/CMOS compatible |
Dimensions | 43mm × 43mm × 27mm |
Pin Configuration

Terminal | Function | Connection |
---|---|---|
+12V | Motor Power (5-35V) | Battery positive |
GND | Ground | Battery negative |
+5V | Logic Power (optional) | 5V (if jumper removed) |
ENA | Channel A Enable | PWM capable pin |
IN1/IN2 | Channel A Control | Digital pins |
IN3/IN4 | Channel B Control | Digital pins |
ENB | Channel B Enable | PWM capable pin |
OUT1/OUT2 | Channel A Motor | Motor A terminals |
OUT3/OUT4 | Channel B Motor | Motor B terminals |
Note: Keep the jumper on +5V terminal if using the onboard 5V regulator
Wiring Diagrams
Basic DC Motor Control
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
// Motor A connections const int enA = 9; const int in1 = 8; const int in2 = 7; void setup() { pinMode(enA, OUTPUT); pinMode(in1, OUTPUT); pinMode(in2, OUTPUT); // Initial state - motor off digitalWrite(in1, LOW); digitalWrite(in2, LOW); } void loop() { // Rotate clockwise at full speed digitalWrite(in1, HIGH); digitalWrite(in2, LOW); analogWrite(enA, 255); // Full speed delay(2000); // Rotate counter-clockwise at half speed digitalWrite(in1, LOW); digitalWrite(in2, HIGH); analogWrite(enA, 128); // Half speed delay(2000); // Motor brake digitalWrite(in1, HIGH); digitalWrite(in2, HIGH); delay(1000); // Motor stop digitalWrite(in1, LOW); digitalWrite(in2, LOW); delay(1000); } |
Stepper Motor Control
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
const int stepsPerRevolution = 200; // Change for your stepper const int in1 = 8, in2 = 7, in3 = 6, in4 = 5; int stepDelay = 5; // ms between steps void stepMotor(int step) { switch(step) { case 0: // 1000 digitalWrite(in1, HIGH); digitalWrite(in2, LOW); digitalWrite(in3, LOW); digitalWrite(in4, LOW); break; case 1: // 1100 digitalWrite(in1, HIGH); digitalWrite(in2, HIGH); digitalWrite(in3, LOW); digitalWrite(in4, LOW); break; case 2: // 0100 digitalWrite(in1, LOW); digitalWrite(in2, HIGH); digitalWrite(in3, LOW); digitalWrite(in4, LOW); break; case 3: // 0110 digitalWrite(in1, LOW); digitalWrite(in2, HIGH); digitalWrite(in3, HIGH); digitalWrite(in4, LOW); break; case 4: // 0010 digitalWrite(in1, LOW); digitalWrite(in2, LOW); digitalWrite(in3, HIGH); digitalWrite(in4, LOW); break; case 5: // 0011 digitalWrite(in1, LOW); digitalWrite(in2, LOW); digitalWrite(in3, HIGH); digitalWrite(in4, HIGH); break; case 6: // 0001 digitalWrite(in1, LOW); digitalWrite(in2, LOW); digitalWrite(in3, LOW); digitalWrite(in4, HIGH); break; case 7: // 1001 digitalWrite(in1, HIGH); digitalWrite(in2, LOW); digitalWrite(in3, LOW); digitalWrite(in4, HIGH); break; } } void setup() { pinMode(in1, OUTPUT); pinMode(in2, OUTPUT); pinMode(in3, OUTPUT); pinMode(in4, OUTPUT); } void loop() { // Rotate CW for(int i=0; i<stepsPerRevolution; i++) { stepMotor(i % 8); delay(stepDelay); } delay(1000); // Rotate CCW for(int i=stepsPerRevolution; i>0; i--) { stepMotor(i % 8); delay(stepDelay); } delay(1000); } |
Tip: For better performance, use the AccelStepper library instead of manual stepping
Advanced Features
Current Sensing
1 2 3 4 5 6 7 8 9 10 11 12 13 |
float readCurrent(int sensorPin) { int rawValue = analogRead(sensorPin); float voltage = rawValue * (5.0 / 1023.0); float current = voltage / 0.1; // 0.1Ω sense resistor return current; } void checkOverCurrent() { if(readCurrent(A0) > 2.0) { // 2A threshold digitalWrite(enA, LOW); // Emergency stop Serial.println("OVER CURRENT!"); } } |
Acceleration Control
1 2 3 4 5 6 |
void smoothStart(int motorPin) { for(int i=0; i<=255; i+=5) { analogWrite(motorPin, i); delay(50); } } void smoothStop(int motorPin) { for(int i=255; i>=0; i-=5) { analogWrite(motorPin, i); delay(50); } } |
Serial Control
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
void processSerialCommands() { if(Serial.available()) { char cmd = Serial.read(); switch(cmd) { case 'F': // Forward digitalWrite(in1, HIGH); digitalWrite(in2, LOW); break; case 'B': // Backward digitalWrite(in1, LOW); digitalWrite(in2, HIGH); break; case 'S': // Stop digitalWrite(in1, LOW); digitalWrite(in2, LOW); break; case '0'...'9': // Speed 0-9 int speed = map(cmd-'0', 0, 9, 0, 255); analogWrite(enA, speed); break; } } } |
Troubleshooting
Motor Not Moving
- Check enable jumpers are in place
- Verify motor power supply is adequate
- Test with direct battery connection
Overheating
- Ensure heatsink is properly attached
- Reduce current draw (smaller motors)
- Add cooling fan if needed
Erratic Behavior
- Add 100μF capacitor across motor terminals
- Separate logic and motor power supplies
- Check for loose connections