About:
This module is tiny and efficient to drive dc motors up to 2.5A without external heat sink. It can drive up to two dc motors or a 4-wire steeper motor, can be operate to change the motor direction and speed using PWM. It also equipped with built-in thermal protection and automatic restore function. It can drive motors from 2v to 10v with zero standby current.
Circuit Diagram:
The module is build to work on two inputs for each motor, if you power up the circuit and supply high pulse to IN1 and low pulse to IN2, then your motor will rotate in forward direction.
If you supply low pulse to IN1 and high pulse to IN2, then your motor will rotate in reverse direction.
If you supply high pulse to both IN1 and IN2, then it will act as brake and your motor will stop rotating.
Working Video:
Code:
/* * Project : Interfacing MX1508 Motor Driver Module with Arduino and pushing commands through serial monitor * Website: www.etechpath.com * Author: PranaySS (Admin) * Link : https://blog.etechpath.com/how-to-use-l298n-motor-driver-module-to-drive-a-dc-motor-using-arduino-mx1508-1627hs/ * Video : https://youtu.be/oUAaZGauyhU */ void setup() { Serial.begin(9600); pinMode(12, OUTPUT); pinMode(11, OUTPUT); pinMode(7, OUTPUT); pinMode(6, OUTPUT); Print_Instructions(); } void loop() { char x; while(Serial.available()) { x = Serial.read(); digitalWrite(12, LOW); digitalWrite(11, LOW); if (x =='1') { FD(); } else if(x =='2') { RV(); } else if(x =='3') { ST(); } else { Serial.println("Invalid Input, Try Again"); delay(100); Print_Instructions(); } } } void Print_Instructions() { Serial.println("Enter number 1, 2 or 3 to control Motor:"); Serial.println("1. FORWARD"); Serial.println("2. REVERSE"); Serial.println("3. STOP"); Serial.println(); } void FD() { digitalWrite(12, HIGH); digitalWrite(11, LOW); digitalWrite(7, HIGH); digitalWrite(6, LOW); Serial.println("Motor 1&2 Forward"); Serial.println(); } void RV() { digitalWrite(12, LOW); digitalWrite(11, HIGH); digitalWrite(7, LOW); digitalWrite(6, HIGH); Serial.println("Motor 1&2 Reverse"); Serial.println(); } void ST() { digitalWrite(12, LOW); digitalWrite(11, LOW); digitalWrite(7, LOW); digitalWrite(6, LOW); Serial.println("Motor 1&2 Stop"); Serial.println(); }
Downloads: