

The L298 Bridge Driver is an integrated circuit (IC) designed for controlling and driving DC motors or stepper motors in a bi-directional mode. It achieves this through two H-bridge configurations, which allow for individual control of two motors simultaneously. The L298 is widely used in robotics, CNC machines, and other applications where precise motor control is required.








| Pin Number | Pin Name | Description |
|---|---|---|
| 1 | Vs | Power supply for the H-bridges (motor voltage) |
| 2 | GND | Ground |
| 3 | Vss | Logic supply voltage |
| 4 & 5 | Out 1 & 2 | Outputs for Motor 1 |
| 6 & 7 | In 1 & 2 | Inputs for controlling Out 1 & 2 |
| 8 | EnA | Enable input for Out 1 & 2 |
| 9 | In 3 & 4 | Inputs for controlling Out 3 & 4 |
| 10 & 11 | Out 3 & 4 | Outputs for Motor 2 |
| 12 | EnB | Enable input for Out 3 & 4 |
| 13 | GND | Ground (Heat Sink) |
| 14 | Vs | Power supply for the H-bridges (motor voltage) |
// Define the L298N control pins
#define ENA 9
#define IN1 8
#define IN2 7
#define IN3 6
#define IN4 5
#define ENB 3
void setup() {
// Set all the motor control pins to outputs
pinMode(ENA, OUTPUT);
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(IN3, OUTPUT);
pinMode(IN4, OUTPUT);
pinMode(ENB, OUTPUT);
}
void loop() {
// Drive motor 1 forward
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
analogWrite(ENA, 200); // Set speed (0-255)
// Drive motor 2 forward
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
analogWrite(ENB, 200); // Set speed (0-255)
delay(2000); // Run for 2 seconds
// Stop both motors
digitalWrite(IN1, LOW);
digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW);
digitalWrite(IN4, LOW);
delay(1000); // Stop for 1 second
}
Q: Can the L298 drive two motors independently? A: Yes, the L298 can control two motors independently using separate input and enable pins for each H-bridge.
Q: What is the maximum voltage and current the L298 can handle? A: The maximum motor supply voltage is 46V, and it can handle up to 4A per channel or 2A per channel for the L298N variant.
Q: Do I need to use flyback diodes with the L298? A: The L298 has internal clamp diodes, but external flyback diodes are recommended for better protection, especially with higher inductive loads.