New here so please bear with me. I'm looking to use the Arduino Uno with some servo's and have noticed on several video's that on setup they move at a slower pace. Is there a code that you can use t make this permanent.
You specify the desired angle, the servo will aim at it at full speed.
You can move the servo at any speed by changing the angle little by little with the code and approaching the target angle.
There are many "servo speed control" tutorials, but it should be noted that many use delay().
With this type of implementation, the Arduino can't do anything else while moving the servo slowly.
It depending on the project, that may or may not be a problem.
If it is a problem, a finite state machine approach could be used. It might take a bit of juggling between the rate at which the machine is run and the angle each step would take.
I think a high enough frame rate and clever accumulation of the sweep angle could make some smooth movement poss.
I got some hits googling
servo speed control state machine arduino
but found nothing that didn’t use delay and incur the penalty for doing.
So make history!
The varSpeedServo library may be of interest.
Nice! At a glance, that looks entirely plausible.
By updating the servo motor positions every 10ms or 20ms, it is possible to calculate at what speed the servo should be at which position.
An examples of that is this:
It uses a millis-timer and the Arduino Servo library. There should be no long delays in the loop().
The varSpeedServo uses a interrupt and generates the servo signal directly without the Servo libray.
You could try both
There are maybe 20 servo libraries to do more things than the Arduino Servo library.
Gotta love wokwi.com, no problem running 5 servos off the UNO 5 volt line.
Thanks Guys for your input, plenty of ideas there. I'm wanting to use the servo's on points so there isn't a great distance/angle to cover. If you've seen Tortoise motors in use on layout the movement takes just over a second and looks pretty realistic, but those motors cost a fortune, around AU$35 to AU$40 each compared with these at around AU$3.
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.