I want to accelerate and decelerate a stepper motor between 2 different speeds using a button.
The acceleration works like a charm however it does not decelerate but instantly takes the lower speed if selected.
What am I missing?
Greetings from the Netherlands
Bart
Your challenge is that AccelStepper is position controlled - it will decide when to accelerate or decelerate based on the current position and target position. It's not really speed controlled
This SpeedStepper library is a rewrite of the AccelStepper library to allow speed control of the stepper motor. The SpeedStepper library lets you change the set motor speed and then accelerates/decelerates to the new set speed using the same algorithm as AccelStepper library. The SpeedStepper library also allow you to set plus and minus limit and a 'home' position. There is a goHome command to return to the home position. You can also set up a 'speed profile' for the stepper to follow and then call startProfile() to execute it.
Limitations: The SpeedStepper library only drives direction and step outputs and so it needs to be connected to a motor driver, such as Easy Driver, to actually drive the stepper motor. The AccelStepper library provides more driving options which could be copied to this library if required.