You don’t have to spend a lot of money to control motors with an Arduino or compatible board. After some hunting around we found a neat motor control module based on the L298N H-bridge IC that can allows you to control the speed and direction of two DC motors, or control one bipolar stepper motor with ease.
The L298N H-bridge module can be used with motors that have a voltage of between 5 and 35V DC. With the module used in this tutorial, there is also an onboard 5V regulator, so if your supply voltage is up to 12V you can also source 5V from the board.
So let’s get started!
First we’ll run through the connections, then explain how to control DC motors then a stepper motor. At this point, review the connections on the L298N H-bridge module.
Consider the image – match the numbers against the list below the image:
12V jumper – remove this if using a supply voltage greater than 12V DC. This enables power to the onboard 5V regulator
Connect your motor supply voltage here, maximum of 35V DC. Remove 12V jumper if >12V DC
GND
5V output if 12V jumper in place, ideal for powering your Arduino (etc)
DC motor 1 enable jumper. Leave this in place when using a stepper motor. Connect to PWM output for DC motor speed control.
IN1
IN2
IN3
IN4
DC motor 2 enable jumper. Leave this in place when using a stepper motor. Connect to PWM output for DC motor speed control
DC motor 2 “+” or stepper motor B+
DC motor 2 “-” or stepper motor B-