This user manual explains how to use an L298N motor driver to control a DC motor with a Raspberry Pi Pico and MicroPython. We will give you a brief introduction to the L298N motor driver module before using it to practise basic dc motor control using our Raspberry Pi Pico board, such as starting, stopping, going backward, and forward.

L298N Motor Driver Module

Dc motors can be controlled through several drivers which are widely available in the market. For this project, we will be using L298N motor driver module as it very easy and relatively inexpensive as well. It is widely used in controlling robots as we can connect up to four motors at once but if we want to control the speed and direction as well than it allows two motors to be connected. Thus, it is perfect for two wheeled robots. This module is mainly used in robotics and in controlling dc and stepping motors.

The L298N motor driver module consists of a L298N motor driver IC ,78M05 5V regulator, 5V jumper enable, power LED, heat sink, resistors and capacitors all combined in an integrated circuit. The diagram below shows all the components consisting inside the module.

The L298N Motor driver IC is powerfully built with a big heat sink. It is a dual channel H bridge motor driver which can be easily used to drive two motors.

The module also has a 78M05 5V regulator which is enabled through a jumper. Keeping the jumper intact, means the 5V regulator is enabled. If the motor power supply is less than 12V then we will power the module through the voltage regulator. The 5V pin in this case acts as an output to power the microcontroller. If the power supply is more than 12V, make sure the jumper is not intact and supply 5V power through the pin separately.

PinOut of L298N Motor driver Module

Let us now look at the pinout of the module.

The L298N Motor driver IC is powerfully built with a big heat sink. It is a dual channel H bridge motor driver which can be easily used to drive two motors.

The module also has a 78M05 5V regulator which is enabled through a jumper. Keeping the jumper intact, means the 5V regulator is enabled. If the motor power supply is less than 12V then we will power the module through the voltage regulator. The 5V pin in this case acts as an output to power the microcontroller. If the power supply is more than 12V, make sure the jumper is not intact and supply 5V power through the pin separately.

L298N Motor Driver Specifications

Driver ModelL298N
Driver ChipDouble H-bridge L298N
Maximum Power25W
Maximum Motor Supply Voltage46V
Maximum Motor Supply Current2A
Driver Voltage5-35V
Driver Current2A
size43x43x26mm

Controlling DC motors through L298N module and MicroPython

Let us now see the details behind controlling the dc motor through the L298N module.

Control Pins

There are two types of control pins found at the bottom right side of the module. One type controls the speed and the other type controls the direction of the motor.

Speed Control (ENABLE) Pins

The speed control pins labeled ENA and ENB on the module, control the speed of the dc motor and turn it ON and OFF.

ENA controls the speed of motor A and ENB controls the speed of motor B. If both of the pins are in a logic HIGH (5V) state, then both the motors are ON and spinning at maximum speed. If both of the pins are in a logic LOW (ground) state, then both the motors are OFF. Through the PWM functionality we can also control the speed of the motor. By default, there is a jumper connected on these pins which keeps these pins in a HIGH state. In order to control the speed, we need to remove the jumper and connect these terminals with the PWM pins of Raspberry Pi Pico and program them in code. The table below demonstrates the logic signals required for controlling Motor A.

ENA Pin stateMotor Action
1(HIGH)ON
O(LOWOFF

If ENA is in a HIGH state, the motor is enabled and if it is in a LOW state then the motor is off.

Direction Control (INPUT) Pins

The direction control pins are the four input pins (IN1, IN2, IN3, IN4) on the module.

Author

Write A Comment