How to program servo routine

I'm trying to make a robot. I dont know code that well. What I need is to have a servo move 0°-45°. A delay And back to 0° repeatedly, When a potentiometer is moved forward. The speed would vary according to the distance the potentiometer is moved. Is this possible with the arduino pro mini 5v 328? Thank you. The motion would be the femer of the leg.

Perfectly possible. There are many examples of moving servos including the Knob example from the IDE which uses a potentiometer to change the ANGLE the servo moves to.

There are also several ways to change the speed of movement.The easiest is to use VarSpeedServo.h instead of the standard Servo.h. Or you can use the technique used in the Sweep example.

Give it a try and post your best attempt then we'll have something to help with.

Steve

The servo sweep example shows how to do the 45-0-45 part. The VarSpeedServo library will help with the adjusting speed part.

Ok varspeedservo can have a series of moves before returning to the beginning. And that series can be controlled by a varspeed function. Maybe. That's it thanks I been looking for this all day. Ill look into this further thanks.