Lesson 14 – Controlling Stepper Motor

Introduction

A stepper motor divides the full rotation into a number of discrete steps. Thus, it is found in applications requiring precise rotational movement. Examples include 3D printers, CNC machines and robotic arms.

Wiring diagram

Program Description

This Arduino program drives a stepper motor via a ULN2003 driver by controlling four digital output pins.

It runs the motor forward for one full revolution (512 steps) at high speed, pauses, then runs it backward for one full revolution at low speed. This repeats indefinitely.

Code flowchart