Arduino Uno ULN2003 Stepper: Industrial Precision Positioning

Professional ULN2003A Darlington array drives 28BYJ-48 5V unipolar stepper through 1/64 microstepping gear reduction delivering 4096 effective steps per revolution (5.625°/step full-step → 0.088°/microstep). 4-phase half-step sequence on pins 8-11 achieves 100-1000 steps/sec velocity range.

Illustration

AccelStepper library implements trapezoidal acceleration/deceleration profiles preventing resonance, skipped steps, and mechanical stress. 5V operation, 240mA/phase, 34mm body, 100g weight supports vertical axis loads up to 300g.

How It Works

A stepper motor moves in discrete increments rather than rotating continuously. Its rotor has many teeth and the stator has several coil phases; energising the phases in sequence pulls the rotor one tooth at a time. A common motor has a 1.8° step angle, giving exactly 200 steps per revolution.

That precision is the point — position can be commanded open loop, with no encoder, because each pulse moves a known amount. The cost is that if the motor misses steps under load, nothing detects it and position is silently lost.

Two driver families dominate. The ULN2003 is a Darlington array used with the 28BYJ-48 unipolar motor, cheap but limited in speed and torque. The A4988 and DRV8825 are current-chopping drivers for bipolar motors, taking just two pins — STEP and DIR — and offering microstepping that subdivides each full step into as many as 32 parts for smoother, quieter motion.

Current-chopping drivers need their current limit set with the onboard trimmer before use. Set too high the motor and driver overheat; too low and the motor loses steps under load. This adjustment is not optional.

Components Needed

  • Arduino Uno
  • ULN2003A Stepper Driver Module
  • 28BYJ-48 5V 4-Phase Stepper Motor
  • Male-to-male jumper wires (10 pieces)
  • Arduino Uno
  • 12V/1A external power supply (optional)

Wiring to the Arduino Uno

Connect STEP to D2 and DIR to D3, with logic power from the 5 V rail and motor power to VMOT. Both grounds must be common.

Fit a capacitor of at least 100 µF across VMOT and GND before applying power. Without it, the inductive spike when the supply connects can destroy an A4988 instantly — this is the single most common way these drivers die.

Never disconnect the motor while the driver is powered. The coils are inductive and breaking the circuit under current generates a destructive voltage spike.

Set the current limit by measuring the reference voltage on the trimmer and applying the formula for your driver — typically Vref = Imax × 8 × Rsense for the A4988.

Driver pinArduino Uno pinFunction
STEPD2One pulse = one step
DIRD3Direction select
ENany digital pinEnable, active LOW
MS1 / MS2 / MS3Jumpers or pinsMicrostep resolution select
VMOT / GNDMotor supply 8–35 VMotor power
VDD / GND5V / GNDLogic supply, grounds common
Illustration

Build and Upload

VCC: Arduino 5V (module power)

GND: Arduino GND

IN1: Arduino Digital Pin 8 (Phase A)

IN2: Arduino Digital Pin 9 (Phase B)

IN3: Arduino Digital Pin 10 (Phase C)

IN4: Arduino Digital Pin 11 (Phase D)

Library Manager → 'AccelStepper'. Verify smooth acceleration from 0→1000→400 steps/sec. Serial Monitor confirms position/speed telemetry.

Physical verification: motor accelerates smoothly without resonance or stall.

4096 steps/rev (1/64); 240mA/phase; 5V; 100g-cm torque; 0.088°/step; -20 to 50°C.

Step 1: IN1 HIGH (1000)

Step 2: IN1+IN2 HIGH (1100)

Step 3: IN2 HIGH (0100)

Step 4: IN2+IN3 HIGH (0110)

Step 5: IN3 HIGH (0010)

Step 6: IN3+IN4 HIGH (0011)

Step 7: IN4 HIGH (0001)

Step 8: IN4+IN1 HIGH (1001)

Example Code

Step/direction control with acceleration, avoiding the stall a sudden start causes. Upload it with the board set to Arduino Uno and open the Serial Monitor at 9600 baud.

Step/direction control with acceleration, avoiding the stall a sudden start causes
const int STEP_PIN = 2;
const int DIR_PIN  = 3;
const int EN_PIN   = 9;

const int STEPS_PER_REV = 200;        // 1.8 degree motor
const int MICROSTEPS    = 16;         // set by MS1/MS2/MS3 jumpers

void stepOnce(unsigned int delayUs) {
  digitalWrite(STEP_PIN, HIGH);
  delayMicroseconds(3);               // A4988 needs >1 us minimum pulse
  digitalWrite(STEP_PIN, LOW);
  delayMicroseconds(delayUs);
}

// Ramp up and down — starting at full speed makes a stepper stall and buzz
void moveSteps(long steps, bool forward) {
  digitalWrite(DIR_PIN, forward ? HIGH : LOW);
  const unsigned int SLOW = 1600, FAST = 350;
  long ramp = min(steps / 4, 400L);

  for (long i = 0; i < steps; i++) {
    unsigned int dly = FAST;
    if (i < ramp)                 dly = SLOW - (SLOW - FAST) * i / ramp;
    else if (i > steps - ramp)    dly = SLOW - (SLOW - FAST) * (steps - i) / ramp;
    stepOnce(dly);
  }
}

void setup() {
  Serial.begin(9600);
  pinMode(STEP_PIN, OUTPUT);
  pinMode(DIR_PIN, OUTPUT);
  pinMode(EN_PIN, OUTPUT);
  digitalWrite(EN_PIN, LOW);          // active LOW enable
}

void loop() {
  long oneRev = (long)STEPS_PER_REV * MICROSTEPS;

  Serial.println("one revolution clockwise");
  moveSteps(oneRev, true);
  delay(700);

  Serial.println("one revolution anticlockwise");
  moveSteps(oneRev, false);
  delay(700);
}

Applications

A stepper motor driver turns up in a wide range of projects. These are the uses where it is the right choice rather than a compromise:

  • 3D printer and CNC axis movement
  • Camera sliders and pan-tilt heads needing repeatable positioning
  • Precision dosing pumps and syringe drivers
  • Telescope tracking mounts
  • Automated valves and dampers where exact position matters

Working with the Arduino Uno

The Arduino Uno is built around the ATmega328P and runs on 5 V logic with 2 KB of SRAM and 32 KB of program flash. These details change how this circuit is wired and what the sketch can do, so they are worth stating plainly before you build.

The Uno runs at 5 V, so most hobby sensor modules connect directly with no level shifting.

With only 2 KB of SRAM, avoid large buffers and prefer the F() macro for constant strings.

The single hardware UART is shared with the USB connection, so heavy Serial printing competes with uploads.

Arduino Uno characteristicValueWhy it matters here
Logic voltage5 VMatches most hobby modules directly
ADC resolution10-bit (0–1023)Sets how finely an analog reading can be resolved
Analog inputsA0–A5 (six channels)Determines how many analog sensors can share the board
PWM outputsD3, D5, D6, D9, D10 and D11Needed for brightness, speed and tone control
I²C pinsA4 (SDA) and A5 (SCL)Fixed by hardware — wiring copied from another board may not match
Interrupt pinsD2 and D3 onlyRequired for counting fast or asynchronous events
Seriala single hardware UART shared with USBMonitor runs at 9600 baud by default

Troubleshooting

Most problems with this module fall into a handful of categories. Work through these before suspecting the part itself:

  • The motor buzzes but does not turn — it is being started too fast. Add acceleration, as the sketch does.
  • The driver burned out on first power-up — the VMOT capacitor was missing.
  • The motor runs hot even when idle — the current limit is set too high, or holding current is unnecessary. Disable between moves.
  • Steps are lost under load — current limit too low, or the speed exceeds available torque.
  • The motor moves the wrong amount — microstep jumpers do not match the MICROSTEPS constant in the sketch.
  • Motion is rough — increase microstepping; full steps are inherently noisy.
  • Code written for an ESP board gives odd analog values — the Arduino Uno uses a 10-bit ADC returning 0–1023; rescale any constant taken from a 12-bit example.
  • An I²C sensor is not found after copying wiring from another Arduino — on the Arduino Uno I²C is on A4 (SDA) and A5 (SCL).

Taking It Further on the Arduino Uno

Once the basic reading works, where you go next depends very much on which board you are using. These are the directions that suit the Arduino Uno specifically:

The Uno’s shield ecosystem is its real advantage. Once the circuit works on a breadboard, a prototyping shield turns it into something permanent that still stacks with a data-logging or Ethernet shield without rewiring.

Logging to an SD card via a shield is the natural next step, since the Uno has no onboard storage and no network. Timestamp each reading with a DS3231 real-time clock so the log survives power cuts with correct times.

Because SRAM is limited to 2 KB, keep logged strings short and write them out immediately rather than buffering. Building a long String in memory is the most common cause of an Uno sketch that runs for hours and then freezes.

Notes and Practical Limits

Steppers hold position by continuously drawing current, so an idle motor is still consuming power and heating. For battery projects, disable the driver between moves — accepting that the shaft can then be turned by hand.

The AccelStepper library implements proper acceleration profiles and non-blocking movement, which matters once a project needs to move two axes at once or do anything else while moving.