Stepper Motor Reference
A 4-wire bipolar stepper motor with two coils (A and B), driven through a stepper driver board (e.g. ULN2003 or L298N) — not directly from GPIO pins.
Pin names
| Name | Description |
|---|---|
| A- | Coil A, terminal − |
| A+ | Coil A, terminal + |
| B+ | Coil B, terminal + |
| B- | Coil B, terminal − |
Attributes
This component has no configurable attributes.
Usage
Connect the four coil terminals to a stepper driver board's outputs, and the driver's
control inputs to four Arduino digital pins. Drive it with the built-in Stepper library.
#include <Stepper.h>
const int STEPS_PER_REV = 2048; // typical for a 28BYJ-48 + ULN2003 driver
// Driver input pins, in the order the library expects
Stepper motor(STEPS_PER_REV, 8, 10, 9, 11);
void setup() {
motor.setSpeed(10); // RPM
}
void loop() {
motor.step(STEPS_PER_REV / 4); // quarter turn clockwise
delay(1000);
motor.step(-STEPS_PER_REV / 4); // quarter turn counter-clockwise
delay(1000);
}
Steppers draw more current than a GPIO pin can safely supply — always drive them through a dedicated driver board, never wire the coils directly to the Arduino.
Examples
| Description | Attrs |
|---|---|
| Default stepper motor | {} |
See also
- Biaxial Stepper — two of these motors combined for 2-axis motion (e.g. CNC/plotter)
- Servo Motor — simpler absolute-angle alternative for single-axis positioning