Tutorial – How to control a DC Motor with L298N

Tutorial – How to control a DC Motor with L298N

A DC Motor is an electrical machines that converts direct current electrical energy into mechanical energy and moreover it can be used to generate energy.

How is made inside?

  • Stator Magnet: generates a magnetic field that will interact with the Coils and will convert the current electrical energy into mechanical energy.
  • Rotor coils: A lot of coils are needed to make spins smoother.
  • Commutator: It’ a rotary switch that reverses the magnetic field twice on every round. This is needed to obtain a rotation. If this won’t happen, the rotor will spin in the opposite sense due to magnetic field generated by the stator.
  • Brushes: Brushes are wired to the power supply.
  • Shaft: Then the shaft will rotate and you it’s the only part that you can really watch from the outside.


Just to verify if the motor works…you can try this schematic. (Be careful, the voltage has to be the right voltage for the DC Motor you are using).

Moreover we will also control DC-Motor with Arduino in next article.

A DC-Motor as generator?

Have you ever read about dynamo? Dynamos are generator. You can try with your DC-Motor. Use this schematic and rotate the shaft with your hands! The LED will turn on!

How to Control them

So we explained how is made inside a DC Motor, but we didn’t explain how to control them.

This tutorial will explain you what is a L298N driver and how to wire a motor and an Arduino board to it.

What is it?

L298N is a dual H-Bridge motor driver. It allows to control two DC motors and it will let you control direction and speed of both the motors.

Moreover, with this module, you can control motors that have voltages between 5V and 35V.


L298N Pinout

So you have to wire:

  • the motor to + and
  • VCC – GND. Than if you want to power the Arduino board through the L298N driver, you can wire the +5 IN/OUT to the Arduino Vin pin.
  • The enable jumper is used to have it always enabled. You can also control it by Arduino, so that you can choose when to have it enabled on not.
  • IN1-IN2-IN3-IN4 are used to control the motor through the Arduino board.


L298N schematic

That’s how to wire the driver to an Arduino board and how to power it.

#define enA 13
#define in1 12
#define in2 11

void setup() 
  pinMode(enA, OUTPUT);
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);

void loop() 
  digitalWrite(in1, LOW);
  digitalWrite(in2, HIGH);
  analogWrite(enA, 100);

Davide Busco

Davide Busco is an engineering student at Federico II University of Naples. He uses his passion and studies to create his projects. He loves be a maker and spread his knowledge. Moreover he has gained the second place in a national makers-tournament between Italian's Universities.

Leave a Reply

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

en_GBEnglish (UK)
it_ITItaliano en_GBEnglish (UK)
%d bloggers like this: