How to use L298N motor driver with Arduino

Spread the love

l298n is a very popular driver to control the motors of the robot. In this article, we will interface ARDUINO with Motor Driver L298N. One Motor Driver can control two motors.

key features of L298N motor driver

This motor driver can operate up to 35 V.

  • L298N works on the principle of Dual H Bridge.
  • It contains a 5v voltage regulator on it.
  • The maximum current it can handle 2 AMPERE.
  • The maximum power consumption of the driver is 20W.
  • L298N can control the speed of the motors.
  • It contains different ports to connect the battery, motors, and ARDUINO.
     L298N    MOTOR DRIVER   SCHEMATIC VIEW

Connection of motor driver with Arduino

  • The Motor Driver contains the two pairs of ports on either side as shown in the image. These ports are connected to the pair of DC Motors.
  • On the front side, it contains a three green phoenix connector. 12v VCC, Gnd and 5v output.
  • There are six pairs of mail buck pins, INPUT 1, INPUT2, INPUT3, INPUT4,      ENABLE A and ENABLE B.
  • INPUT1 and INPUT2 pins are the positive and negative terminals of Motor 1.
  • INPUT3 and INPUT4 pins are the positive and negative terminals of Motor 2.
  • ENABLE A and ENABLE B are the PWM pins and these pins are connected to the ARDUINO to control the speed of the Motor 1 and Motor 2.
l298n motor driver connection with arduino
l298n motor driver connections with Arduino

How the Dual H-Bridge works

h-bridge

An H bridge is an electronic circuit that switches the polarity of a voltage applied to a load. These circuits are often used in robotics and other applications to allow DC motors to run forwards or backward

Arduino Code explain

You need Arduino software for this if you don’t have read ower article How to install Arduino IDE. Upload the code on Arduino.

If everything is correct the motor output is like.

  • Initially, MOTOR 1 is rotated in a clockwise direction.
  • After 3 seconds it is rotated in an anticlockwise direction.
  • Now after 3 seconds MOTOR 2 is rotated in the anticlockwise direction.
  • After 3 seconds MOTOR 1 is rotated in the clockwise direction.
  • After 3 seconds MOTOR 2 is rotated in the clockwise direction.

Follow me on Instagram

By @robotic_electronics –
vineetchoudhry1910 and
nobel_chowdary

Add a Comment

Your email address will not be published. Required fields are marked *