I am using the AccelStepper library and 1 single stepper motor. I home the stepper using two limit switches and the following code
long getEndpoints() {
stepper1.setSpeed(-2500);
while (!digitalRead(startSwitch)) {
stepper1.runSpeed();
}
stepper1.setCurrentPosition(0);
long startPoint = stepper1.currentPosition();
Serial.println(startPoint);
stepper1.setSpeed(2500);
while (!digitalRead(endSwitch)) {
stepper1.runSpeed();
}
long endPoint = stepper1.currentPosition();
Serial.println(endPoint);
return startPoint, endPoint;
}
The steppers move and the selected speed during this.
But when I go to move the stepper to a select position it runs very very slowly. it seems to be defaulting to the speed set in the moveTo function, unless I take it out of a while loop and just run it in the void loop function
Have You inspected any of the example codes for AccelStepper?
Lots of members use the library functions the wrong way. There's surely a manual/document explaining how the different functions work.
putting the moveTo function inside of the while loop seems to fix it. I read over the examples and documentation. I'm not 100% sure why it works but I won't question it.