So you want to set your servo speed, and trying that with delay() is making everything else in your code stop? Here's the solution.
- Make sure LC_baseTools as well as LC_slowServo are installed on your machine, using the Arduino Library manager.
- In your sketch add the line.. #include <slowServo.h>
- Instead of creating standard Arduino servo objects for your sketch, create slowServos. And when you create a slow servo, you need to give it a pin number. For example : slowServo myServo(2);
- In your setup(); function, call myServo.begin(); For each of your servos. This sets up your servos for use.
- In your loop(); function, add the line idle(); to the top. This runs everything that wants to be run in the background. Like these servos.
- To set a position, call the method myServo.setDeg(angle);. Your servo will begin to move to that position.
- To set speed, call the method myServo.setMsPerDeg(Ms); Your servo will delay this much time per degree movement. IE 0 means full blast.
- WARNING!!! DO NOT USE delay(); FOR ANYTHING! This WILL stop everything, no matter what. Replace your delay(); calls with sleep(); calls. This stops your main loop, but keeps the servos and everything else that runs in the background, running.
- You can call myServo.moving(); to see if your servo is moving or not.
- You can call myServo.stop(); to stop your servo.
That's all there is to it.
Here is a wokwi example : https://wokwi.com/projects/358434260375219201