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
}