Rotating a servo a certain amount of degrees over a certain amount of time

I have been programming and tinkering for a little while now. And i have gotten to a skill level where if i come up with a project idea i am usually able to make the code for it, or at the very least research my way to a solution.

But now i have hit a complete dead end. I wanted to input three things: starting degree (0-180), ending degree and the time it would take the servo to move between those two positions in seconds for example.

As i said i have hit a complete dead end, i dont even know where to start.

How would you guys solve this?


lets just say that the inputs are all taken care off and now you have all the values you need as ints, what would the math look like?

the servo is just a normal sg90

Isn't there a variable speed servo library?


TolpuddleSartre: Isn't there a variable speed servo library?

Yes but it doesn't accept a specific time to move from A to B. Just a notional speed to move at. I suppose you could try calibrating the various speeds.

But it's probably easier to use the Sweep technique of moving in small increments (which is what VarSpeedServo does internally) and calculate the time required for each increment yourself. That's all you can do with servos because they have no actual speed control. You have to move small amounts and pause between moves. E.g. if you want to move 30 degrees in 10 seconds pause for 1/3 second after each 1 degree move.