Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

LAB 9: Controlling DC Motors using L298N Motor Driver

1. Objectives:
- Learn how DC motor works
- How to control the speed and direction of DC motor
- How to control a DC motor using L298N driver
- How to control two DC motors using L298N driver

2. Introduction
a. DC Motor
DC Motor has two wires:
Positive wire: usually red
Negative: usually black

How it works
When you power the 12 V DC motor by a 12V power source:
12V and GND to the positive wire and negative wire, respectively: the DC motor
rotates at maximum speed in the clockwise direction
12V and GND to the negative wire and positive wire, respectively: the DC motor
rotates at maximum speed in the anti-clockwise direction
If we provide power to DC motors below 12V, the motor still rotates but not at
maximum speed. IT means if we change the voltage of the power supply, we can
change the speed of the DC motor. However, this method is not used in practice
because of the difficult in controlling the voltage of the power source. Instead, we fix
the voltage of the power source and control the speed of the DC motor via a PWM
signal. The more duty cycle the PWM is, the higher the DC motor rotates.
How to control DC motor using Arduino
Controlling DC motor includes two factors: speed and direction. Arduino can generate
the PWM signal. However, this PWM signal has low voltage and current, we cannot
use it to control the DC motor, we need to use a hardware driver in between Arduino
and DC motor. The driver does two works:
- Amplify the PWM signal from Arduino (current and voltage) for speed control
- Receive the control signal from Arduino to swap pole of power supply  for
direction control.

b. About L298N Driver


L298N Driver can be used to control DC motor and stepper motor.
L298N Driver can control two DC motor indepently at the same time, called motor A
and motor B. L298N Driver has 13 pins:

3. Lab exercise
Choose components required (Arduino Uno, L293D, Virtual terminal, DC motor (active),
POT-HG) then connect them using Protues, as following circuit:
a. Program Arduino to control the speed of the DC motor by generating a PWM signal to
the ENA pin of L298N.
- Simulate the circuit after programming.
b. The spinning direction of a motor can be controlled by applying a logic HIGH/LOW
ton IN1 and IN2 pins.

- Program Arduino to control the direction in clockwise and anti-clockwise of DC motor


via L298N Driver.
- Simulate the circuit after programming.
c. Write a code on Arduino to stop DC motor spinning by two ways:
 Control the speed to 0
 Control IN1, IN2 pins to the same value (LOW or HIGH)
- Simulate the circuit after programming.
Name: Student Code: Class: Lab:
1. Circuit
2. Algorithm flowchart
3. Code and explanation
4. Summary

You might also like