Driving a Bipolar Stepper through an L298N H-Bridge

Driving a Bipolar Stepper through an L298N H-Bridge — photograph from the project archive.

The L298N project demonstrates a stepper sequence implemented directly in Arduino code. It includes a custom StepperL298N class, motor winding references and photographs of the driver and motor on the bench.

How the project works

The class stores full-step and half-step transition tables. Each call to step selects the next four-output state, with direction determined by which half of the table entry is used. The active loop selects full stepping, performs 200 steps with a 10 ms delay between steps, disables both bridges and waits one second.

The motor object is constructed with pins 6, 7, 8 and 9. Enable outputs on pins 10 and 5 control the two bridge channels. Several alternative movement sequences remain commented out and do not run in the saved version.

Hardware and configuration

ItemIn the supplied code
Bridge controlD6, D7, D8, D9
Enable signalsD10 and D5
Active modeFull step
Active sequence200 steps, then a one-second pause

Working with the supplied code

Match the coil pairs to the driver outputs and use the motor datasheet to select a suitable supply and current arrangement. The generic wiring diagrams in the folder should be checked against the actual pin order in this sketch.

Review the two memset calls before extending the lookup tables: their value and length arguments are reversed, making the requested length zero. Correct initialization matters if new states or modes are added. The program illustrates sequencing, not acceleration planning or closed-loop position verification.

Driving a Bipolar Stepper through an L298N H-Bridge — photograph from the project archive.
Driving a Bipolar Stepper through an L298N H-Bridge — photograph from the project archive.

Video demonstration

Arduino Stepper H Bridge L298N — Ovidiu Carstea on YouTube

Source code and project files

Browse this project on GitHub. The files below are useful starting points for the sketches and references discussed in this post.

Download the used libraries (ZIP, 14.7 MB).

These notes describe the archived source and project media. The sketches have not been rebuilt or tested on hardware for this article.

Scroll to Top