#include
const int stepsPerRevolution = 40; // change this to fit the number of steps per revolution
// for motor
// initialize the stepper library on the motor shield
Stepper myStepper(stepsPerRevolution,12,13);
// give the motor control pins names:
const int pwmA = 3;
const int pwmB = 11;
const int brakeA = 9;
const int brakeB = 8;
int previous = 0;
void setup() {
Serial.begin(9600);
// 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);
digitalWrite(pwmA, HIGH);
digitalWrite(pwmB, HIGH);
digitalWrite(brakeA, LOW);
digitalWrite(brakeB, LOW);
// initialize the serial port:
Serial.begin(9600);
// set the motor speed (for multiple steps only):
//myStepper.setSpeed(500);
}
void loop() {
//Get Motor up to 500 speed and turn 500 times / Total turns 2030
myStepper.setSpeed(400);
myStepper.step(30);
myStepper.setSpeed(500);
myStepper.step(2000);
//Slow Motor down and stop
myStepper.setSpeed(300);
myStepper.step(10);
myStepper.setSpeed(200);
myStepper.step(10);
myStepper.setSpeed(100);
myStepper.step(10);
delay(1000);
//Get Motor up to 500 speed and turn 500 times / Total turns 2030
myStepper.setSpeed(400);
myStepper.step(-30);
myStepper.setSpeed(500);
myStepper.step(-2000);
//Slow Motor down and stop
myStepper.setSpeed(300);
myStepper.step(-10);
myStepper.setSpeed(200);
myStepper.step(-10);
myStepper.setSpeed(100);
myStepper.step(-10);
delay(1000);
}