Help with Adafruit V2 motor shield and Stepper Motor

Hi all! I was wondering if you all can take a look at my code and see if there is anything wrong with it. My plan is to run the stepper motor continuously for a set time that I give it at a certain speed.

Thanks all beforehand for giving it a look.

#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_PWMServoDriver.h"



Adafruit_MotorShield AFMS = Adafruit_MotorShield(); // This addresses the shield in question (In this case it would be a seperate sheild from the DC Motors)

Adafruit_StepperMotor *mystepperMotor1 = AFMS.getStepper(200, 1); // This assigns the stepper motor to the port and also the steps the motor is capabale in a rotation. In this case M1 and M2 is port #1 and M3 and M4 is port #2.



void setup() {
  // put your setup code here, to run once:

  Serial.begin(9600);
  Serial.println("Spout Motor");

  AFMS.begin();

  mystepperMotor1->setSpeed(50); // Sets speed
  mystepperMotor1->step(200,FORWARD,DOUBLE); // Sets steps, direction, and coil activation
  mystepperMotor1->step(200,BACKWARD,DOUBLE); // Sets steps, direction, and coil activation



}

void loop() {
  // put your main code here, to run repeatedly:    

  mystepperMotor1->step(200,FORWARD,DOUBLE); //Runs motor forward
  Serial.println("Run stepper motor forward");
  delay(10000);                              // Runs motor for 10 seconds

  

  Serial.println("Stepper motor off");
  delay(1500);            //Delay 1.5 seconds
  exit(0);                //Exit loop
  

}

You have not told us what your code actually does ?

...R
Stepper Motor Basics

You set the speed to 50, then step for 200 steps, and imagine this will run for 10 seconds - it won't,
it runs for 200 steps, about 1.2 seconds at 50rpm. 10 seconds at 50rpm is about 1667 steps (8.33
revolutions)

Robin2:
You have not told us what your code actually does ?

...R
Stepper Motor Basics

Sorry Robin2. I am waiting for my stepper motor to arrive but have been doing research on how to
Move a stepper motor for a set rate for a given time that I give it. At least that's what I'm hoping I can make it do that.

MarkT:
You set the speed to 50, then step for 200 steps, and imagine this will run for 10 seconds - it won't,
it runs for 200 steps, about 1.2 seconds at 50rpm. 10 seconds at 50rpm is about 1667 steps (8.33
revolutions)

MarkT,

How would I go about making it run continuously for a set speed that I give it and a time that I set it to? I have been tying to use the adafruit instruction with the given library but there isn't much information that I could find.

anyone?

jpmc:
How would I go about making it run continuously for a set speed that I give it and a time that I set it to?

You could adapt the 2nd example in Simple Stepper Program to do that.

...R