How to Use L298n to Control Dc Motor With Arduino UNO

by sujay dcruze in Circuits > Arduino

704 Views, 3 Favorites, 0 Comments

How to Use L298n to Control Dc Motor With Arduino UNO

Screenshot_2021-05-29-15-23-35-28.jpg
Untitled.png

my 2nd project is to use l298n to control dc motors. I have find difficult to use l293d because of some voltage problem so,I have used l298n for the new project. In next our next project we can use l293d. l298n is good to control it gives more voltage to dc motor such us input 12volt and output 10volt,it is the best motor driver for beginners. Now lets move into our project. :)

Supplies

1694c122a823cc5d96809d644b14f419bd515304.png
download.jpg
download.jpg

material I used :-

l298n,Arduino ide, Arduino Uno, Jumper wires, 9volt battery(two)

Setting Up Our Circuit

Untitled.png

In this step you can wire the driver like in the picture or change it to adapt it to your project, don't forget to wire the GND from the driver with the GND from Arduino, for the powering here I used a 9v battery, you can power it from a power source or battery, also the +5v pin from the driver can power your Arduino if you put it in Vin from Arduino board.

Arduino IDE

download.png

Programs written using Arduino Software (IDE) are called sketches. These sketches are written in the text editor and are saved with the file extension .ino. The editor has features for cutting/pasting and for searching/replacing text. The message area gives feedback while saving and exporting and also displays errors. The console displays text output by the Arduino Software (IDE), including complete error messages and other information. The bottom righthand corner of the window displays the configured board and serial port. The toolbar buttons allow you to verify and upload programs, create, open, and save sketches, and open the serial monitor.

Uploading

Untitled.png
download.jpg

first open Arduino IDE and verify the program and upload it.

int ena = 2;

int in1 = 3;

int in2 = 4;

int in3 = 5;

int in4 = 6;

int enb = 7;


void setup() {

 pinMode (ena,OUTPUT);

 pinMode (in1,OUTPUT);

 pinMode (in2,OUTPUT);

 pinMode (in3,OUTPUT);

 pinMode (in4,OUTPUT);

 pinMode (enb,OUTPUT);

 

 digitalWrite(in1,HIGH);

 digitalWrite(in2,LOW);

  digitalWrite(enb,HIGH);

  

 digitalWrite(in3,HIGH);

 digitalWrite(in4,LOW);

  digitalWrite(ena,HIGH);

}


void loop() {

}

any other projects you want command me!!!

Downloads

Motor6.png
Motor5.png
Motor4.png
Motor3.png
Motor2.png
Drecription

The L298N is an integrated monolithic circuit in a 15- lead Multiwatt and PowerSO20 packages. It is a high voltage , high current dual full-bridge driver de-signed to accept standard TTL logic level sand drive inductive loads such as relays, solenoids, DC and stepping motors. Two enable inputs are provided to enable or disable the device independently of the in-put signals .The emitters of the lower transistors of each bridge are connected together rand the corresponding external terminal can be used for the connection of an external sensing resistor. An additional Supply input is provided so that the logic works at a lower voltage.

Its schematic diagram is as shown in figure (a):

(a)Schematic diagram for motor drive module

Features

1) High operating voltage, which can be up to 40 volts;

2) Large output current, the instantaneous peak current can be up to 3A;

3) With 25W rated power;

4) Two built in H-bridge, high voltage, large current, full bridge driver, which can be used to drive DC motors, stepper motors, relay coils and other inductive loads.

5) Using standard logic level signal to control.

6) Able to drive a two-phase stepper motor or four-phase stepper motor, and two-phase DC motors.

7) Adopt a high-capacity filter capacitor and a freewheeling diode that protects devices in the circuit from being damaged by the reverse current of an inductive load, enhancing reliability

8) The module can utilize the built-in stabilivolt tube 78M05 to obtain 5v from the power supply. But to protect the chip of the 78M05 from damage, when the drive voltage is greater than 12v, an external 5v logic supply should be used.

9) Drive voltage: 5-35V; logic voltage: 5V

10) PCB size: 4.2 x 4.2 cm

Pin Function

Its pin functions are as shown in table (1):

(1) Table for L298N pin functions

Principle

The driver module can drive two motors. The enabled terminals ENA and ENB are effective at high level. The control mode and state of motor A are as shown in table (2):

(2) Table for control mode and state of motor A

If you want to regulate the speed of motor A by PWM, you need to set IN1 and IN2, confirm the rotational direction of the motor, and then output PWM pulses for enabled terminals. Please note the motor is in the free stop state when the signal of enabled terminal is 0. When the enabled signal is 1, if IN1 and IN2 are 00 or 11, the motor is in brake state, and the motor stops rotating. If IN1 is 0 and IN2 is 1, the motor A rotates clockwise; if IN1 is 1 and IN2 is 0, the motor A rotates counterclockwise. This is the control method for motor A. The control method for motor B is the same as that for motor A.