# Moving Gradually

### Part 4: Moving your Servo Gradually Between Minimum and Maximum Positions

Create new variables to hold the max and min positions that you wrote down in the part 2. Don’t use my values, use yours.

<figure><img src="https://3423273789-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjRgHmD322MUgRPOyqMLh%2Fuploads%2FF2WIZTQmFRQlqtacKEaB%2Fimage11?alt=media" alt=""><figcaption></figcaption></figure>

Change your old code to look more like this. Once you have made the change, the code will not allow your servos to exceed the maximum position.

<figure><img src="https://3423273789-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjRgHmD322MUgRPOyqMLh%2Fuploads%2FTblauJVuj47NJHDovo6o%2Fimage3?alt=media" alt=""><figcaption></figcaption></figure>

You could also change the speed of your servos by changing the value that the servo position variable gets added/subtracted by  in these lines of code…

<figure><img src="https://3423273789-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjRgHmD322MUgRPOyqMLh%2Fuploads%2FAU8mURVd0E72OKcsLEsL%2Fimage2?alt=media" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
You might be done... stop and think about how you want your servo to move!
{% endhint %}
