I have been using Accelstepper for some time now to move multiple steppers and I'm going through my code again to clean up the movement and had a question about a short piece of code for homing a stepper on startup.
I was using moveTo() and thought I would just use setSpeed() and runSpeed() to achieve the same thing as moveTo() without using steps. I tell it to run if the hall sensor I have is HIGH but when the hall sensor goes LOW I would have thought the stepper would stop moving since the hall sensor is no longer HIGH but it hits the sensor and then starts running in the opposite direction. I added in an if statement to stop the motor when it is LOW but I can't figure out why the motor moved the way it did.
carriage.setMaxSpeed(10000.0);
while (digitalRead(carriagetop) == HIGH) {
carriage.setSpeed(800);
carriage.runSpeed();
}
if (digitalRead(carriagetop) == LOW) {
carriage.setSpeed(0);
}