Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Component Documentation

How to Use L298n: Examples, Pinouts, and Specs

Image of L298n
Cirkit Designer LogoDesign with L298n in Cirkit Designer

Introduction

The L298n is a dual H-bridge motor driver IC designed to control the direction and speed of DC motors and stepper motors. It is capable of driving two motors simultaneously, making it an essential component in robotics, automation, and motor control projects. The L298n can handle high currents and voltages, making it suitable for a wide range of applications, from small hobbyist robots to industrial automation systems.

Explore Projects Built with L298n

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Battery-Powered Line Following Robot with ATmega328P and L298N Motor Driver
Image of Arduino-Controlled Line Following Robot with Dual DC Motors and L298N Driver: A project utilizing L298n in a practical application
This circuit is a line-following robot controller. It uses a Nano 3.0 ATmega328P microcontroller to read inputs from a line sensor and control two DC motors via an L298N motor driver. Power is supplied by a 9V battery regulated through an XL4015 DC buck converter.
Cirkit Designer LogoOpen Project in Cirkit Designer
Arduino UNO Controlled Robot with Bluetooth and Ultrasonic Sensor
Image of vhjv: A project utilizing L298n in a practical application
This is a robotic control circuit featuring an Arduino UNO microcontroller that interfaces with two SG90 servo motors for movement, an HC-SR04 ultrasonic sensor for distance measurement, and an HC-05 Bluetooth module for wireless communication. The L298N motor driver is incorporated for potential motor control, and the system is powered through a standard power jack.
Cirkit Designer LogoOpen Project in Cirkit Designer
Wi-Fi Controlled Quad DC Motor Driver System
Image of abhinand: A project utilizing L298n in a practical application
This circuit is designed to control four DC motors using an L298N motor driver module, which is interfaced with an ESP8266 NodeMCU microcontroller. The NodeMCU's digital pins (D1-D6) are connected to the input pins of the L298N to control the speed and direction of the motors. A 12V battery provides power to the motors through the motor driver, and also powers the NodeMCU through a voltage regulator on the L298N.
Cirkit Designer LogoOpen Project in Cirkit Designer
ESP32-CAM Controlled Surveillance Robot with Wi-Fi and Servo Pan/Tilt Mechanism
Image of sam: A project utilizing L298n in a practical application
This circuit is designed to control a mobile platform with four DC motors for movement, two servos for directional control, and an ESP32-CAM module for wireless video streaming. The L298N motor driver interfaces with the ESP32-CAM to drive the motors based on commands received over WiFi, allowing for remote directional control. The ESP32-CAM also handles the servo positioning and streams live video, enabling the user to control and monitor the platform remotely through a web interface.
Cirkit Designer LogoOpen Project in Cirkit Designer

Explore Projects Built with L298n

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of Arduino-Controlled Line Following Robot with Dual DC Motors and L298N Driver: A project utilizing L298n in a practical application
Battery-Powered Line Following Robot with ATmega328P and L298N Motor Driver
This circuit is a line-following robot controller. It uses a Nano 3.0 ATmega328P microcontroller to read inputs from a line sensor and control two DC motors via an L298N motor driver. Power is supplied by a 9V battery regulated through an XL4015 DC buck converter.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of vhjv: A project utilizing L298n in a practical application
Arduino UNO Controlled Robot with Bluetooth and Ultrasonic Sensor
This is a robotic control circuit featuring an Arduino UNO microcontroller that interfaces with two SG90 servo motors for movement, an HC-SR04 ultrasonic sensor for distance measurement, and an HC-05 Bluetooth module for wireless communication. The L298N motor driver is incorporated for potential motor control, and the system is powered through a standard power jack.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of abhinand: A project utilizing L298n in a practical application
Wi-Fi Controlled Quad DC Motor Driver System
This circuit is designed to control four DC motors using an L298N motor driver module, which is interfaced with an ESP8266 NodeMCU microcontroller. The NodeMCU's digital pins (D1-D6) are connected to the input pins of the L298N to control the speed and direction of the motors. A 12V battery provides power to the motors through the motor driver, and also powers the NodeMCU through a voltage regulator on the L298N.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of sam: A project utilizing L298n in a practical application
ESP32-CAM Controlled Surveillance Robot with Wi-Fi and Servo Pan/Tilt Mechanism
This circuit is designed to control a mobile platform with four DC motors for movement, two servos for directional control, and an ESP32-CAM module for wireless video streaming. The L298N motor driver interfaces with the ESP32-CAM to drive the motors based on commands received over WiFi, allowing for remote directional control. The ESP32-CAM also handles the servo positioning and streams live video, enabling the user to control and monitor the platform remotely through a web interface.
Cirkit Designer LogoOpen Project in Cirkit Designer

Common Applications:

  • Robotics (e.g., controlling wheels or robotic arms)
  • Automation systems
  • Stepper motor control
  • Conveyor belts
  • DIY motorized projects

Technical Specifications

The L298n is a robust and versatile motor driver IC. Below are its key technical details:

Key Specifications:

  • Operating Voltage: 5V to 46V
  • Output Current: Up to 2A per channel (4A total with both channels)
  • Logic Voltage: 5V
  • Control Logic Levels: High (2.3V to 5V), Low (0V to 1.5V)
  • Power Dissipation: 25W (with proper heat sinking)
  • Built-in Protection: Thermal shutdown and overcurrent protection
  • Number of Channels: 2 (dual H-bridge)
  • PWM Frequency: Up to 25 kHz

Pin Configuration and Descriptions:

The L298n IC has 15 pins, but it is often used with a breakout module for easier connections. Below is the pin configuration for the IC:

Pin Number Pin Name Description
1 Enable A Enables or disables motor A (High = Enabled, Low = Disabled)
2 Input 1 Logic input to control motor A direction (works with Input 2)
3 Output 1 Output to motor A terminal 1
4 Ground (GND) Ground connection
5 Ground (GND) Ground connection
6 Output 2 Output to motor A terminal 2
7 Input 2 Logic input to control motor A direction (works with Input 1)
8 VSS (Logic Supply) Logic voltage supply (typically 5V)
9 Enable B Enables or disables motor B (High = Enabled, Low = Disabled)
10 Input 3 Logic input to control motor B direction (works with Input 4)
11 Output 3 Output to motor B terminal 1
12 Ground (GND) Ground connection
13 Ground (GND) Ground connection
14 Output 4 Output to motor B terminal 2
15 Input 4 Logic input to control motor B direction (works with Input 3)
16 VS (Motor Supply) Motor voltage supply (up to 46V)

For the L298n breakout module, additional pins like a 5V regulator jumper and onboard terminals for motor and power connections are included.

Usage Instructions

The L298n can be used to control two DC motors or one stepper motor. Below are the steps to use it in a circuit:

Connecting the L298n:

  1. Power Supply:

    • Connect the motor power supply to the VS pin (or the +12V terminal on the module).
    • Connect the logic power supply (5V) to the VSS pin.
    • Connect all GND pins to the ground of your circuit.
  2. Motor Connections:

    • Connect the terminals of motor A to Output 1 and Output 2.
    • Connect the terminals of motor B to Output 3 and Output 4.
  3. Control Pins:

    • Use Input 1 and Input 2 to control the direction of motor A.
    • Use Input 3 and Input 4 to control the direction of motor B.
    • Use Enable A and Enable B to enable or disable the motors. These pins can also be connected to a PWM signal to control motor speed.
  4. Optional:

    • If using the breakout module, ensure the onboard 5V regulator jumper is set correctly based on your power supply.

Example Code for Arduino UNO:

Below is an example of how to control a DC motor using the L298n and an Arduino UNO:

// Define L298n control pins
const int enableA = 9;  // PWM pin for motor A speed control
const int input1 = 8;   // Direction control pin for motor A
const int input2 = 7;   // Direction control pin for motor A

void setup() {
  // Set control pins as outputs
  pinMode(enableA, OUTPUT);
  pinMode(input1, OUTPUT);
  pinMode(input2, OUTPUT);

  // Initialize motor A to stop
  digitalWrite(input1, LOW);
  digitalWrite(input2, LOW);
  analogWrite(enableA, 0);  // Set speed to 0
}

void loop() {
  // Rotate motor A forward at 50% speed
  digitalWrite(input1, HIGH);
  digitalWrite(input2, LOW);
  analogWrite(enableA, 128);  // 50% duty cycle (128 out of 255)
  delay(2000);  // Run for 2 seconds

  // Rotate motor A backward at full speed
  digitalWrite(input1, LOW);
  digitalWrite(input2, HIGH);
  analogWrite(enableA, 255);  // 100% duty cycle
  delay(2000);  // Run for 2 seconds

  // Stop motor A
  digitalWrite(input1, LOW);
  digitalWrite(input2, LOW);
  analogWrite(enableA, 0);  // Set speed to 0
  delay(2000);  // Wait for 2 seconds
}

Best Practices:

  • Use a heat sink with the L298n to prevent overheating during high-current operation.
  • Ensure the motor voltage and current ratings are within the L298n's specifications.
  • Use decoupling capacitors near the power supply pins to reduce noise.
  • For PWM control, use a frequency below 25 kHz for optimal performance.

Troubleshooting and FAQs

Common Issues:

  1. Motor Not Running:

    • Check if the Enable pins are set to HIGH.
    • Verify the power supply connections and ensure sufficient voltage is provided.
    • Ensure the motor connections are correct.
  2. Overheating:

    • Attach a heat sink to the L298n IC.
    • Reduce the motor load or use motors with lower current requirements.
  3. Erratic Motor Behavior:

    • Check for loose connections or poor soldering.
    • Add decoupling capacitors to the power supply lines.
  4. PWM Not Controlling Speed:

    • Ensure the PWM signal is connected to the Enable pins.
    • Verify the PWM frequency is within the L298n's supported range.

FAQs:

Q: Can the L298n drive stepper motors?
A: Yes, the L298n can drive bipolar stepper motors by controlling the two H-bridge channels.

Q: What is the maximum current the L298n can handle?
A: The L298n can handle up to 2A per channel, but a heat sink is recommended for high-current applications.

Q: Can I use the L298n with a 3.3V microcontroller?
A: Yes, but you may need level shifters to ensure proper logic level compatibility.

Q: Is the onboard 5V regulator always active on the breakout module?
A: No, the 5V regulator is active only if the jumper is set and the motor supply voltage is above 7V.

By following this documentation, you can effectively use the L298n motor driver in your projects!