Trying to drive a RS 5350372 Stepper Motor with an R3 motor Shield.

The problem is it won't turn an exact revolution of 400 steps.

It also won't work properly unless the speed is 100 rpm. Doesn't seem to like going lower than that.

The Code

#include <Stepper.h>

const int stepsPerRevolution = 400; // change this Number to fit the number of steps per revolution
// for your motor

// initialize the stepper library on the motor shield
Stepper myStepper(stepsPerRevolution, 12,13);

// give the motor control pins names: = this converts the pin voltage signals to the outputs A+- B+-
const int pwmA = 3;
const int pwmB = 11;
const int brakeA = 9;
const int brakeB = 8;
const int dirA = 12; // = direction of rotation
const int dirB = 13; // = direction of rotation

void setup()
{
//stepper
// set the PWM and brake pins so that the direction pins // can be used to control the motor:
pinMode(pwmA, OUTPUT);
pinMode(pwmB, OUTPUT);
pinMode(brakeA, OUTPUT);
pinMode(brakeB, OUTPUT);
//stepper

//stepper
myStepper.setSpeed(100);
}

void loop(){

digitalWrite(pwmA, HIGH);//=5 v
digitalWrite(pwmB, HIGH);
//digitalWrite(brakeA, LOW);//=0volts
//digitalWrite(brakeB, LOW);
myStepper.step(4000); // =360 degrees for 1.8 degree stepper
digitalWrite(pwmA, LOW);//=5 v
digitalWrite(pwmB, LOW);
//digitalWrite(brakeA, HIGH);//=0volts
//digitalWrite(brakeB, HIGH);

delay(1000);
//digitalWrite(4,LOW);

// forward button
//digitalWrite(4,HIGH);

digitalWrite(pwmA, HIGH);//=5 v
digitalWrite(pwmB, HIGH);
//digitalWrite(brakeA, LOW);//=0volts
//digitalWrite(brakeB, LOW);
myStepper.step(-4000); // =360 degrees for 1.8 degree stepper
//digitalWrite(brakeA, HIGH);//=0volts
//digitalWrite(brakeB, HIGH);
digitalWrite(pwmA, LOW);//=5 v
digitalWrite(pwmB, LOW);

delay(1000);
}

End of Code

I have the wires of the motor connected correctly to the motor shield and it will move back and forth just fine, though it doesn't move a single revolution, it either moves just over or under one rev.

          myStepper.step(4000);  // =360 degrees for 1.8 degree stepper

4000 steps for a 400 step per revolution stepper is not one full revolution.

Why are you not using a real stepper motor driver?

Sorry, it was at 400, must have changed it when I was trying to fix it.

Also what driver would you suggest?

Post a link to the datasheet for your motor. That data is needed to identify a suitable stepper driver.
What power supply are you using for the motor (volts and amps)

You may get some useful info in Stepper Motor Basics

If you are able, with your present driver, to make the motor move 1 step you should be able to get it to move 400 steps. Is it possible the motor is missing some steps - perhaps because you are trying to move it too fast. Your existing motor shield may not be ideal for higher speeds.

...R