Arduino Stepper Motor Tutorial

How to use an old six wire stepper motor and control it with an Arduino. This was an old stepper motor that I pulled out my junk pile, I'm not sure what it came from, I think it was an old printer from the 80s. In this tutorial I'll show you how we can figure out how to connect the stepper motor to an Arduino and control it using the Adafruit motor shield. The easiest way to do this is with a simple multimeter. If you don't have one, it's worth buying one as you can get one for just a few bucks nowadays, and even the cheapest one you can find is good enough for this sort of project.

## Step 1: Measure and Record the Resistance for All Six Wires

Most stepper motors come with four, six, or eight wires. This motor uses six wires. What we need to do is measure the resistance from one motor wire to another. This is because of the way stepper motors are made, stepper motors will have two coils and since this motor has six wires that means there are 3 wires per coil. Each of the two coils will have a common wire attached to the center of the coil, we don't want to use this wire. The way that we can determine which wire this is his by measuring resistance, and the resistance from one of the center wires to one of the other wires on the same coil will be smaller than the other pairs. If two wires are not on the same coil, you will measure an open circuit. Here are the resistances is that I measured

## Step 2: Determine Which Wires to Ignore.

For this example that means we want to connect the orange and blue wires, and the white and red wires, we will ignore the gray wire and brown wire, because they have a smaller resistance. The Adafruit motor shield can run two stepper motors using four wires for each so we're going to connect white and red and orange and blue to stepper motor port to.

The adafruit motor shield Has a library called AFmotor , which is a high level library running the motor shield, we will use this library.

Here's the code copied from the stepper motor example that is included with the AF motor library .

```#include <AFMotor.h>

// this code is public domain, enjoy!

// Connect a stepper motor with 48 steps per revolution (7.5 degree)
// to motor port #2 (M3 and M4)
AF_Stepper motor(50, 2);

void <strong>setup</strong>() {
<strong>Serial</strong>.begin(9600);           // set up Serial library at 9600 bps
<strong>Serial</strong>.println("Stepper test!");

motor.setSpeed(30);  // 10 rpm
}

void <strong>loop</strong>() {
<strong>Serial</strong>.println("Single coil steps");
motor.step(50, FORWARD, SINGLE);
motor.step(50, BACKWARD, SINGLE);
}

```

## Step 4: Running the Sketch

Here's a video of the sketch running I put a little piece of paper on the stepper motor just to observe how long it took to make a full rotation, the example code assume steps per rotation, but after tinkering with it for a while I believe this particular motor is not 48, but 50 steps per rotation. Here is another example application of a motor shield.

<p>Thanks for this tutorial! Very helpful :D</p><p>I have a question:</p><p>How can i determine a starting position for a stepper motor ?</p><p>I want to put my stepper indicator at 180 degrees trigonometrically and work from 180 to 0 (trigonometrically).</p><p>Any ideas ?</p>
<p>When I measuring ohm any wire with red wire show half of resistance of any wire combination. But no open circuit show. have any problem in my motor?</p>
<p>Is it allowed topost urls here? www.youtube.com testing.. :v</p>
<p>can i run six wire spteper motor without driver ic </p>
<p>thanks</p>
<p>nice, basically what you did is to run a unipolar motor as a bipolar. But that is perfectly possible... as long as the motor has 2 common wires</p>
<p>Nice!</p>