I am trying to run a stepper motor at a specific speed without a time constraint. I want it to run indefinitely, but must run at the specific speed. I have created the code below, but there is a slight pause between loops. Can anyone help me come up with a way to run the stepper at the constant speed without a time limitation? I am using an Uno R3 and the official motor shield.
#include <Stepper.h>
// Map our pins to constants to make things easier to keep track of
const int pwmA = 3;
const int pwmB = 11;
const int brakeA = 9;
const int brakeB = 8;
const int dirA = 12;
const int dirB = 13;
// The amount of steps for a full revolution of your motor.
// 360 / stepAngle
const int STEPS = 170;
// Initialize the Stepper class
Stepper myStepper(STEPS, dirA, dirB);
void setup() {
// Set the RPM of the motor
myStepper.setSpeed(5);
// Turn on pulse width modulation
pinMode(pwmA, OUTPUT);
digitalWrite(pwmA, HIGH);
pinMode(pwmB, OUTPUT);
digitalWrite(pwmB, HIGH);
// Turn off the brakes
pinMode(brakeA, OUTPUT);
digitalWrite(brakeA, LOW);
pinMode(brakeB, OUTPUT);
digitalWrite(brakeB, LOW);
}
void loop() {
// Move the motor X amount of steps
myStepper.step(10000);
}