01: Contents:
- Why use the motor driver?
- Types of motor drivers
- Applications of motor driver
- L298N Dual h-bridge module introduction
- l298N dual H-bridge specifications
- L298N dual H-bridge pin configuration
- Motor driver controller logic
- Interfacing L298N module with Arduino
Motor driver H-bridge l298 with Arduino
01: Why use the motor driver?:
As its name shows that a driver so it can drive not just a motor but also some other applications. The motors can not run on lower current so we need a higher current that current is generated by the motor driver.
02: Types of Motor Drivers:
There are many different motor drivers available. And if we talk about IC’s the two most common ic’s are (l293d, l298). we can make a circuit using these two IC’s. We can also make motor drivers using Transistors and switches logic.
But making the motor driver circuit using transistors and switches could be less efficient. So just to avoid some messy work or we can say any sort of extra work we use the ready made IC’s. There is no need to explain the core concept of using H-bridges in depth here. Other than Linear integrated IC the other types are bipolar stepper motor driver, H-bridge motor driver the servo motor driver and the DC motor driver and brushless motor driver.
03: Applications of the Motor driver:
- DC motor controlling
- Relay and solenoid switching
- Stepping motor
- LED and bulb displays
- Automotive applications
- Audio-visual equipment
- Car audios
- Navigation systems
- Robotics
04: L298N Dual h-bridge module introduction:
We can drive two motors using this module. As its name suggests Dual H-bridge there are 2 outputs for motors. This module is developed using l298 IC. So we can use it for driving DC motors or other motors and can be easily used for robotics purposes etc.
See below the sources portion for Pinout configuration of the Dual H-Bridge L298N module and l298n motor driver connection with Arduino.
05: l298N dual H-bridge specifications:
- The supply area Vs: 7V to 35V
- Source 5V from the board can also be used.
- The peak current of driven part Io: 2A
- Maximum power consumption: 20W (when the temperature T = 75 °C)
- Dimensions: 43 x 43 x 26mm
- Weight: 26g
06: L298N dual H-bridge pin configuration:
- Motor 1 out
- Motor 2 out
- 5v: The 5v input pin
- En1: (The Enables PWM signal pin for driving speed of Motor 1)
- En2: (The Enables PWM signal pin for driving speed of Motor 2)
- 5V Enable pin: not necessary if we are using a supply voltage 12V DC or greater. Just remove the jack.
07: Motor driver controller logic:
Motor 1 | Motor 2 | A | B | Action to perform |
Low | Low | 0 | 0 | Stop |
High | Low | 12V | 0 | Clockwise |
Low | High | 0 | 12V | Anti-clockwise |
High | High | 12V | 12V | Brake |
l298n motor driver connection with Arduino
08: L298N circuit diagram:
Connect your module with Arduino as according to your connection. See the image below for l298n motor driver connection with Arduino.
Run and vary the speed of motors by changing the values of enable pins. It is Arduino dc motor speed control using PWM.
Arduino h bridge code
09: Arduino H bridge code:
int m1e = 3; int motor11 = A2; int motor12 =A3; int motor2e = 5; int motor21 = A4; int motor22 = A5; void setup(void) { pinMode(motor1e, OUTPUT); pinMode(motor11, OUTPUT); pinMode(motor12, OUTPUT); pinMode(motor2e, OUTPUT); pinMode(motor21, OUTPUT); pinMode(motor22, OUTPUT); } void loop(void) { analogWrite(motor1e,250); digitalWrite(motor11, HIGH); //Motor 1 drives forward digitalWrite(motor12, LOW); analogWrite(motor2e,250); digitalWrite(motor21, HIGH); //Motor 2 drives forward digitalWrite(motor22, LOW); delay(1000); analogWrite(motor1e,0); digitalWrite(motor11, HIGH); //motor 1 stops digitalWrite(motor12, HIGH); analogWrite(motor2e,0); digitalWrite(motor21, HIGH); motor 2 stops digitalWrite(motor22,HIGH); }