The SmartElex L298N Motor Driver with Onboard Arduino Uno is an integrated module designed to control motors with ease using the Arduino platform. This component combines the robust L298N motor driver, capable of driving two DC motors or one stepper motor, with the functionality of an Arduino Uno. It is ideal for hobbyists, educators, and engineers who require a simple and efficient way to incorporate motor control into their projects.
Pin Number | Pin Name | Description |
---|---|---|
1 | ENA | Enable motor A |
2 | IN1 | Input 1 for motor A |
3 | IN2 | Input 2 for motor A |
4 | OUT1 | Output 1 for motor A |
5 | OUT2 | Output 2 for motor A |
6 | ENB | Enable motor B |
7 | IN3 | Input 1 for motor B |
8 | IN4 | Input 2 for motor B |
9 | OUT3 | Output 1 for motor B |
10 | OUT4 | Output 2 for motor B |
11 | +5V | 5V output (if 12V applied to Vm) |
12 | GND | Ground |
// Define motor driver pins
#define ENA 9
#define IN1 8
#define IN2 7
#define ENB 6
#define IN3 5
#define IN4 4
void setup() {
// Set all the motor driver pins as 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
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
analogWrite(ENA, 200); // PWM signal for speed control
// Drive motor B backward
digitalWrite(IN3, LOW);
digitalWrite(IN4, HIGH);
analogWrite(ENB, 200); // PWM signal for speed control
delay(2000); // Run motors for 2 seconds
// Stop both motors
digitalWrite(IN1, LOW);
digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW);
digitalWrite(IN4, LOW);
delay(1000); // Wait for 1 second
}
Q: Can I drive a stepper motor with this module? A: Yes, the L298N can drive a bipolar stepper motor. You will need to adjust the control signals accordingly.
Q: What is the function of the ENA and ENB pins? A: ENA and ENB are used to enable and control the speed of motors A and B, respectively, through PWM signals.
Q: Can I use this module without an external power supply? A: It depends on the current requirements of your motors. If they require more current than the Arduino Uno can supply, an external power source is necessary.
For further assistance, consult the SmartElex community forums or technical support.