L298N Dual H-Bridge and bi-polar stepper motor
Figure 1 L298N Dual H-Bridge connected to a bi-polar stepper motor.

Interface Arduino Controlling L298N H-Bridge Motor Control

by Lewis Loflin

Earlier we looked at L298N Motor Controller Theory and Projects to understand the basic operation of the L298N dual H-bridge motor controller. In this section I've connected the L298N to a bi-polar stepper motor and connected it to the Arduino micro-controller. Note the motor voltage is the voltage rating of the stepper motor up to 40 volts and a current limit of four amps.

Note the motor voltage will have to doubled. For example if a unipolar motor is rated at 5-volts then in the bipolar mode will be 10-volts. This is due to the coils being operated in series.

The Arduino series of micro-controllers are an outstanding value for the hobbyist and student to learn the basics of programming and interfacing micro-controllers. In this example in both hardware and programming the code below will operate the stepper motor through the L298N.

The steppers I used in the example are all 7.5 degrees per-step and require 48 steps to go 360 degrees. Stepper motors are very accurate and often don't need feedback to tell position.

A bi-polar stepper motor has only two coils and operates by reversing the polarity unlike a unipolar stepper motor that operates by switching four coils on/off.

3-wire connection for L29N to bi-polar stepper.
Figure 2

Here we have used only three connections to the Arduino micro-controller to operate the stepper motor. We tied ENA and ENB together and used two inverters from a 74LS04. We could still leave ENA and ENB separate if one wishes. In the program below simply remove any statements relating to ENB, yellow, or black which will free up three digital pins. It would also be a good idea change "#define orange 11" to #define orange 10" then wire digital pin 10 to IN3.

Download the Arduino code l298n_arduino.txt copy and past to the Arduino compiler.

Pre-assembled L298N board
Figure 3

Shown above is a pre-assembled board I bought off Ebay for $8 with shipping. This included power connectors, diodes, LED indicators, and even a 5-volt regulator. This is in my opinion the smart way to go to save time, money, and effort.

Stepper Motors

Web site Copyright Lewis Loflin, All rights reserved.
If using this material on another site, please provide a link back to my site.