Servo motor dosn't move

Hello ALL,

When i use the sweep servo example the motor moves very well, but when i change the code so instead of using a loop to move from degree 0 to degree 179 , i just write the desired 179 directly servo keeps giving a sound tik tik wzout moving.

Here is the code i used instead of sweep example

// Sweep
// by BARRAGAN http://barraganstudio.com
// This example code is in the public domain.

#include <Servo.h>

Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created

void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
myservo.write(179);
}

void loop()
{
}

Thanks in advance.

Maybe it's already at 179.... did you try other values?

yes i tried to change it from 179 degree to 1 degree but its the same just tik tik sound … and when i use sweep example again it moves perfectly.

Your exact code works for me, so I have no idea what's wrong.

I tried various values, compile and upload, servo moves as expected.

95% of servo issues on these forums are due to an inadequate power supply for the servo, this thread is unlikely to be an exception.

MarkT: 95% of servo issues on these forums are due to an inadequate power supply for the servo, this thread is unlikely to be an exception.

I would agree with you and power is usually my first response too....except for the fact that the OP says sweep works, but the code he posted doesn't, and then sweep works again just after that.

totally agree with u its not a power problem thats why i said that i used sweep example and it worked fine to eliminate the debate that its a power or hardware connection problem

What happens if you change 179 to (say) 159?

...R

At extreme control values, the servo may be against the internal rotation hard stop. Try some mid range control values to see if the noise stops.

JimboZA:

MarkT: 95% of servo issues on these forums are due to an inadequate power supply for the servo, this thread is unlikely to be an exception.

I would agree with you and power is usually my first response too....except for the fact that the OP says sweep works, but the code he posted doesn't, and then sweep works again just after that.

But that's exactly why I believe its a power problem... Motor drive proportional to position error, sweep has a position error of 1 degree at each point, far less than 179 degrees, so will demand far less current.