how to make a servo move slower?

I have a servo and i want to make it move 39 degrees. i used the following code but i want to make the movement slower. When i set delay at the end of the code, the servo delays to start moving but the speed is high.Have anyone any idea how can i make the movement slower?

#include <Servo.h>
int button1 = 7; //button pin, connect to ground to move servo
int press1 = 0;
Servo servo1;

void setup()
pinMode(button1, INPUT);
digitalWrite(7, HIGH); //enable pullups to make pin high

void loop()
press1 = digitalRead(button1);
if (press1 == LOW)
else {

I don't reckon it's a good idea to connect the servo to the 5V pin on the Arduino as suggested in the tutorial, your servo could draw more current than the board can handle resulting in smoke.


Its an appauling idea - people have been trying to get some of these pages changed for ages.

You could use a servo library that has a "speed" setting, such as varspeedservo, which is very straight-forward.

Or you could use the normal servo library but there are some things that the Arduino has to do, because you can not set the speed, but you can set the time needed for a movement from A to B, which could eventually translate in a slower servo motion.

Anyway, please use code tags next time.

MarkT: Its an appauling idea - people have been trying to get some of these pages changed for ages.

First off, what I am going to say should be taken with a small grain of salt; I haven't made any objective measurements of anything regarding this topic. While I agree that the page needs changes, I don't think the idea should be eliminated.

It is certainly true that a servo, upon startup, likely draws a lot of current. However, it is generally for a very brief length of time, which the 7805 can easily tolerate, as the datasheet illustrates:

The time is so brief that there isn't a chance for the over-current protections to kick in (though I tend to doubt that a standard-sized unloaded servo will pull more than 1.5 amps - nevermind the 2.2 A maximum).

Most likely, if there is any voltage sags to the ATMega - they are very brief; in most cases they won't reset the uC.

After the servo starts moving, of course, the current draw drops - and is likely low enough that the 7805 can supply both the servo and the Arduino easily without overheating (at least for the brief amount of time the servo is moving).

So - with the above said, where is the problem? Well - the problem can be illustrated in multiple ways:

  1. First off, most of the people trying to learn from this page, and others like it, are newbies with little to no understanding of datasheets, how to read them, what they are, that they even exist or are a "thing" to review. Furthermore, even if they had them in front of them, trying to understand them would be next to impossible due to their lack of knowledge.

  2. Secondly, that page and others make no distinction between various servos - micro, standard, large, jumbo, giant, etc (as well as continuous rotation and "winch" servos, among others) - nor how much current each can potentially draw. This can easily lead to a newbie concluding that all servos are the same, when it would be ill advised to attach a "jumbo" winch servo to the Arduino's 5 volt output, but a micro or standard sized servo would be ok.

  3. Furthermore, no mention is made that such a circuit should be for "testing purposes only" - and that the servo being tested should not have any load placed on its output shaft (with an explanation as to why - namely the increase in startup and running currents, etc).

  4. No mention is also made that such a circuit - even with an unloaded servo - should not be used continuously, as while the load is probably within the maximum specs of the 7805, it is still presenting a high-average to high load on it, which should be avoided.

  5. Finally, nothing is discussed about how to properly supply power to one or more servos - a proper discussion would entail detailing what voltages and currents a typical servo (of various sizes) needs, along with how to properly supply such needs.

In short - that page makes the fatal error that the person reading it has a level of understanding about certain electronic principles which, in general is not likely to be true. This was likely unintentional, either from error, or from the common bias of "not thinking like a newbie" during the implementation.

Whatever the cause, I don't believe the baby should be thrown out with the bathwater, but rather the page be updated to give the reader as much knowledge on the subject as possible, to educate them about the reasoning and the problems behind the circuit, how to properly solve them, and to remind them that the circuit is for demonstration, educational, or testing purposes only, and should not be used in part or whole of a "final design".

Now - I leave everyone with a couple of related interesting links I found:

Reverse Engineering a Counterfeit 7805

Hack a 7805 Voltage Regulator to Sense Temperature

That second link is obviously a real hack job, and should only be considered as something to play with (much like how you can use an LED to sense light), and definitely not for any real-world projects.