The L298N Motor Driver Controller Board Module by HiLetgo is a versatile and robust dual H-bridge motor driver integrated circuit (IC) designed to control two DC motors or one stepper motor. It is widely used in robotics, DIY projects, and various electronic applications where precise motor control is required. The L298N allows for independent control of speed and direction for each motor, making it an ideal choice for projects that require complex movements.
Pin Number | Pin Name | Description |
---|---|---|
1 | OUT1 | Motor channel 1 output A |
2 | OUT2 | Motor channel 1 output B |
3 | OUT3 | Motor channel 2 output A |
4 | OUT4 | Motor channel 2 output B |
5 | VS | Motor power supply input (5V-35V) |
6 | GND | Ground |
7 | VSS | Logic power supply input (5V) |
8 | IN1 | Control input for motor channel 1A |
9 | IN2 | Control input for motor channel 1B |
10 | IN3 | Control input for motor channel 2A |
11 | IN4 | Control input for motor channel 2B |
12 | ENA | PWM input for speed control of motor channel 1 |
13 | ENB | PWM input for speed control of motor channel 2 |
// Example code to control a DC motor with L298N Motor Driver and Arduino UNO
const int motorPin1 = 8; // IN1 on the L298N
const int motorPin2 = 9; // IN2 on the L298N
const int enablePin = 10; // ENA on the L298N
void setup() {
pinMode(motorPin1, OUTPUT);
pinMode(motorPin2, OUTPUT);
pinMode(enablePin, OUTPUT);
}
void loop() {
// Set motor direction clockwise
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
// Set speed to maximum
analogWrite(enablePin, 255);
delay(2000); // Run for 2 seconds
// Set motor direction counterclockwise
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, HIGH);
delay(2000); // Run for 2 seconds
// Stop the motor
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
delay(2000); // Stop for 2 seconds
}
Note: The above code is a simple demonstration of controlling a DC motor's direction and speed using the L298N Motor Driver. For more complex applications, additional code and hardware setup may be required.