Search Here

INTERFACING OF ARDUINO WITH MOTOR DRIVER

INTERFACING OF ARDUINO WITH MOTOR DRIVER

In this session, ARDUINO interfacing with Motor Driver L298N is discussed.

Motor Driver is used to control the motion of the motors. One Motor Driver can run two motors. Motor Driver L298N especially had a heat sink to dissipate the heat produced. It can with stand a voltage upto 35 V.

L298N works on the principle of Dual H Bridge.

It contains a voltage regulator.

The maximum current up to 2 AMPERE .

The maximum power consumption of 20W .

L298N can control the velocity of the motors.

It contains different ports to connect battery, motors and ARDUINO.



L298N    MOTOR DRIVER   SCHEMANTIC   VIEW

CONNECTING THE L298N TO ARDUINO

The connection of motor driver to the ARDUINO and pair of DC Motors is discussed in the following lines:

Ø The Motor Driver L298N contains the two pairs of ports on either sides as shown in fig 1 and these ports are connected to the pair of DC Motors.

Ø In the front side it contains a three pin terminal. It is the battery terminal and a 12V DC Battery can be connected. It contains a VCC pin, GROUND pin and a 5V ARDUINO pin.

Ø It contains another set of 6 pins. INPUT 1, INPUT2, INPUT3, INPUT4,      ENABLE  A and ENABLE B.

Ø INPUT1 and INPUT2 pins are the positive and negative terminals of Motor 1 and these are connected to the ARDUINO to control the rotation of the Motor 1.

Ø INPUT3 and INPUT4 pins are the positive and negative terminals of Motor 2 and these are connected to the ARDUINO to control the rotation of the 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.


PRINCIPLE  OF  WORKING  OF  MOTOR DRIVER



ARDUINO PROGRAM OF L298N

 

const int IN1 = 2;

const int IN2 = 3;

const int IN3 = 4;

const int IN4 = 5;

//const int ENA = 5;

//const int ENB = 6;

 

void setup()

{

  pinMode(IN1, OUTPUT);

  pinMode(IN2, OUTPUT);

  pinMode(IN3, OUTPUT);

  pinMode(IN4,OUTPUT);

 // pinMode(ENA,OUTPUT);

 // pinMode(ENB,OUTPUT);

}

void loop() {

 // analogWrite(ENA,255);

 // analogWrite(ENB,255);


  digitalWrite(IN1,LOW);

  digitalWrite(IN2,HIGH);

  digitalWrite(IN3,LOW);

  digitalWrite(IN4,LOW);

  delay(3000);


  digitalWrite(IN1,HIGH);

  digitalWrite(IN2,LOW);

  digitalWrite(IN3,LOW);

  digitalWrite(IN4,LOW);

  delay(3000);


  digitalWrite(IN1,LOW);

  digitalWrite(IN2,LOW);

  digitalWrite(IN3,HIGH);

  digitalWrite(IN4,LOW);

  delay(3000);


  digitalWrite(IN1,LOW);

  digitalWrite(IN2,HIGH);

  digitalWrite(IN3,LOW);

  digitalWrite(IN4,LOW);

  delay(3000);


  digitalWrite(IN1,LOW);

  digitalWrite(IN2,LOW);

  digitalWrite(IN3,LOW);

  digitalWrite(IN4,HIGH);

  delay(3000);


  exit(0);

}


After the complete writing of the above program in ARDUINO IDE , you can dump the code into the ARDUINO board.


ARDUINO CODE EXPLANATION OF L298N

After the successful connection of the L298N to the ARDUINO and MOTORS and successful program dumping, the rotation of the motors is done in the following way:


·        Initially the MOTOR 1 is rotated in clockwise direction.

·        Then, after 3 seconds it is rotated in anticlockwise direction.

·        Now after 3 seconds MOTOR 2 is rotated in anticlockwise direction.

·        Then after 3 seconds MOTOR 1 is rotated in clockwise direction.

·        Finally after 3 seconds MOTOR 2 is rotated in clockwise direction.

 


CONCLUSION

The above discussed information is used to program the ARDUINO and interface it with the L298N and control the rotation of the two DC Motors . The information and the discussion is the simple control of the motors and it is used to develop the motion in the robotics projects and this blog can easily help to develop the robo car that can be controlled autonomously or semi-autonomous. This blog on L298N can help to develop the connection of Motor Driver with the different manual control components like NRF module and the Double Pole Double Throw Switch commonly known as DPDT Switch. Finally this blog made you to learn the initial and basic knowledge related to the robotic projects.


 


More Posts

Compact Fluorescent Lamp Circuit (CFL)

Arduino UNO

SMD Register coding

Thermoelectric Generators AKA Peltier Modules

Capacitors

PN Junction Diode

Introduction To Raspberry Pi

Gas sensor

What Are Resistors?

INTERFACING OF ARDUINO WITH ULTRASONIC SENSOR

Archived