Basic programing and start up for stepper sketch

I am for the first time hooking up a stepper motor to an arduino uno with an Arduino motorshield R3 mounted to it.

I have taken a six lead unipolar motor and wired it so that, as I understood it, could be used as a bipolar stepper.

the first coil had for the NPR 23 : Black and green with a center tap Yellow, then for the second coil Red and Blue with the center tap White.

The instructions I found where to take the center tap Yellow and White and connect them to the ground terminal then hook up Blk to A+ term and GRN to A- then hook up RED to B+ terminal and BLU to B- terminal.

I plugged in my external 12v 1.5a power supply, and since there is only the blink code on there, the motor just ticked. Which is fine but I wanted to mention all of this incase I did it wrong. I don’t know if Arduino R3 is a really new product cause I hadn’t found any examples out there to just duplicate what they did. But I’m excited so far.

The example Program I had in the Stepper sketch was:

#include <AFMotor.h>

AF_Stepper motor(48, 2);

void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println(“Stepper test!”);

motor.setSpeed(10); // 10 rpm

motor.step(100, FORWARD, SINGLE);

void loop() {
motor.step(100, FORWARD, SINGLE);
motor.step(100, BACKWARD, SINGLE);

motor.step(100, FORWARD, DOUBLE);
motor.step(100, BACKWARD, DOUBLE);

motor.step(100, FORWARD, INTERLEAVE);
motor.step(100, BACKWARD, INTERLEAVE);

motor.step(100, FORWARD, MICROSTEP);
motor.step(100, BACKWARD, MICROSTEP);

I clicked on Verify and got lot of errors.

Does anyone have a simple sketch I could use just to try and run the stepper forward an backwards. Or know where there is a library with test sketchs. The only one I found on this site was for use with a potentiometer.

Any help would be very much appreciated! XD

I clicked on Verify and got lot of errors.

I clicked Verify and got no errors. So, you must have done something wrong. Most likely, failed to download and install the library correctly.

Without knowing what errors you got, we can't help you.

seandelgatto2001: I clicked on Verify and got lot of errors.

Read this:,97455.0.html

Point 6:

If you get an error, post the error (copy and paste). Not just "I got an error".

Sorry for not posting the error. Been a rough week working 60 hour graveyard shifts lol

I ended up using a new script:

#include <Stepper.h> //include the function library
#define STEPS 200 //3.75 deg motor (96 steps per rev)
Stepper stepper(STEPS, 1, 2, 3, 4); //create the stepper

void setup()
int i;
stepper.setSpeed(30); //set speed to 30 rpm
delay(1000); //pause for effect
stepper.step(200); //move 360 deg one direction
delay(1000); //pause for effect
stepper.step(-200); //move 360 deg in the other direction
delay(1000); //pause
stepper.setSpeed(60); //speed up
for (i=0;i<5;i++) {
stepper.step(20); //wave the flag

void loop()

I notice a small reaction in the stepper motor and only the LED for A+ side flickers the rest don’t so I think that the program does not have the right pins on program line : Stepper stepper(STEPS, 1, 2, 3, 4)

[ ]

I looked at the diagram and it looks as though it states DIRA is off 9 and DIRB is off 15, towards the IC1 side

But then it gives a 1 and 2 off of IC2 A then 12 and 13 off IC2 D

Maybe im just really tired but Im thinking that on the programing side it should be Stepper stepper(STEPS, 1, 2, 12, 13)

Does that seam right or should it be Stepper stepper(STEPS, 9, 15)

If anyone can verify that would be much appreciated. I realize Im extremely new to this, and the book I got includes everything except running a stepper motor, servo and basically stuff I would be using a stepper for, so I ordered another one off amazon.

For sure, the motor shield does not use pin 1. That is a serial port pin.

so would Stepper stepper(STEPS, 9, 15) be the correct one? I wish the Arduino shield r3 had more documentation but I guess they were expecting us to pretty much know what we are doing lol! I mostly stumbled onto the arduino through the dragon frame site and was going to use dragon frame to control it but thought that maybe using my own programing would be better. Which I still think will be, once i get the hang of it.

It looks to me like you need to use pins 9, 11, 12, and 13 for you Stepper instance, but what order they should be in, I couldn't tell you.