Driving a $0.40 Stepper with Arduino

by Ryan Schenk on March 10, 2010

I recently bought 250 stepper motors (part number 21-02485-03) for a sculpture that I’m working on, for the low price of 40 cents a piece! Even if you don’t buy them in bulk, they are still really cheap.

There are several driver circuits available for this motor, which were very helpful in figuring out the strange wiring inside this motor. However, none of the above drivers played nicely with the Arduino Stepper Library, which uses Tom Igoe’s stepper driver circuit. It took an evening to figure out how to connect this stepper to Tom’s driver and the Arduino stepper library, so I thought I would post it here.

The first step is to cut the white wire, which turns the stepper from a weird hybrid into a normal bipolar stepper. The links above will explain this in more detail if you’re curious.

The next step is to correlate the four wires on the motor to Tom Igoe’s circuit and the Arduino stepper library. These use the numbers 1-4 to describe the wires coming out of the motor, and order does matter. With the 21-02485-03, the wires numbered 1-4 correlate to the Red, Blue, Yellow, and Black wires respectively.

With this knowledge we can easily hook up our stepper to Tom’s circuit and start using the Arduino Stepper Library immediately. Here’s a diagram of Tom Igoe’s 4-wire circuit, with the Arduino code after it. The IC chip used is a L293D H-Bridge and note that the notch in the IC faces to the right (a bit hard to tell).


Image developed using Fritzing.

/* 

  Drives the 21-02485-03 Stepper Motor attached
  to Tom Igoe's four-wire driver circuit
  
*/

#include 


// Change these to the pin numbers of each color wire 
#define YELLOW  8
#define RED     9
#define BLACK   10
#define BLUE    11

#define SPEED 200 // RPM


#define LED_PIN 13

// create an instance of the stepper class, specifying
// the number of steps of the motor and the pins it's
// attached to
//
// Order matters here when giving it the pins
Stepper stepper(20, RED, BLUE, YELLOW, BLACK);


void setup()
{
  // set the speed of the motor to 30 RPMs
  stepper.setSpeed(SPEED);
  
  pinMode(LED_PIN, OUTPUT);
}

void loop()
{
  
  stepper.step(100);
  delay(300);

  stepper.step(-100);
  delay(300);
}

3 comments

Driving a $0.40 Stepper with Arduino…

I recently bought 250 stepper motors (part number 21-02485-03) for a sculpture that I’m working on, for the low price of 40 cents a piece! Even if you don’t buy them in bulk, they are still really cheap.

There are several driver circuits available…

by pligg.com on July 27, 2010 at 9:25 am. Reply #

Thanks for this. It’s been helpful.

Any advice on getting an rpm of less than 1 rpm?

by Robert on February 8, 2011 at 8:11 pm. Reply #

There are only 20 steps per rev… I think going below 1 rpm is going to be very jerky. Maybe you could try half-stepping?

by Ryan Schenk on February 8, 2011 at 8:19 pm. Reply #

Leave your comment

Required.

Required. Not published.

If you have one.