The L298P Drive Shield is a versatile motor driver shield designed for use with the Arduino platform. It is based on the L298P motor driver IC which allows for the control of two DC motors or one stepper motor. The shield is capable of driving motors with a voltage range typically from 5V to 12V, making it suitable for a wide array of robotics and DIY projects.
Pin Number | Function | Description |
---|---|---|
1 | ENA | Enables PWM signal for Motor A |
2 | IN1 | Control pin for Motor A direction |
3 | IN2 | Control pin for Motor A direction |
4 | ENB | Enables PWM signal for Motor B |
5 | IN3 | Control pin for Motor B direction |
6 | IN4 | Control pin for Motor B direction |
7 | +5V | Regulated 5V output (if jumper is in place) |
8 | GND | Ground |
9 | +12V (Vin) | Motor power supply input (5V to 12V) |
Power Connections:
Motor Connections:
Control Connections:
#include <Arduino.h>
// Motor A
int ENA = 5; // Speed control
int IN1 = 2; // Direction
int IN2 = 3; // Direction
// Motor B
int ENB = 6; // Speed control
int IN3 = 4; // Direction
int IN4 = 7; // Direction
void setup() {
// Set all the motor control pins to outputs
pinMode(ENA, OUTPUT);
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(ENB, OUTPUT);
pinMode(IN3, OUTPUT);
pinMode(IN4, OUTPUT);
}
void loop() {
// Drive Motor A forward at full speed
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
analogWrite(ENA, 255); // Set speed to maximum (PWM value 0 to 255)
// Drive Motor B backward at half speed
digitalWrite(IN3, LOW);
digitalWrite(IN4, HIGH);
analogWrite(ENB, 127); // Set speed to half of maximum
delay(2000); // Run motors for 2 seconds
// Stop both motors
digitalWrite(IN1, LOW);
digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW);
digitalWrite(IN4, LOW);
analogWrite(ENA, 0); // Set speed to zero
analogWrite(ENB, 0); // Set speed to zero
delay(1000); // Wait for 1 second
}
Q: Can I control a stepper motor with this shield? A: Yes, the L298P Drive Shield can control a bipolar stepper motor using the Motor A and Motor B connections.
Q: What is the maximum current the shield can handle? A: The shield can handle up to 2A per channel continuously, with peak currents of up to 3A for short pulses.
Q: Can I use this shield with other microcontrollers besides Arduino? A: Yes, as long as the microcontroller provides compatible logic voltage levels and can generate PWM signals.