Servo Working strangely

Hello everyone. I have been working on a project for a few weeks now, see http://arduino.cc/forum/index.php/topic,101231.15.html

Anyway. I moved the entire thing over from a duemilanove to a nano, in order to put it on a pcb. A new problem seems to have cropped up, and I am not really sure whats causing it.

The code below moves a servo to push a button.

void pushButton()
{

myservo.write(122);
delay(500);
myservo.write(90);
Serial.print("Button Pushed");
}

The problem is that sometimes, the servo moves to "122" and never responds back. Also the arduino seems to hang, and no further commands, or programming is possible until a reset. Another funny thing is that even when it works, it seems to ignore the delay completely, and instead holds the servo at "122" for at least 2 seconds before going back to "90"

This seems really odd to say the least. I can post the rest of the code, but its pretty long and will take two posts.

Edit I should probably also mention that I did not have this problem with the duemilanove. It almost as if the nano is doing the servo move and then crashing, and is moving back to "90" as part of its reboot. Other times its hanging.

It almost as if the nano is doing the servo move and then crashing, and is moving back to "90" as part of its reboot. Other times its hanging.

Sounds like you have a less than adequate power setup.

I was powering the servo off the nano +5 Out. It seems to work on the Dumnuluv, so it just came over from the breadboard.

Never power a servo from a logic supply, you risk damaging the delicate logic components.

A servo is a MOTOR. It will take a lot of current from its supply and put inductive spikes on its supply if you are unlucky. Run it from a separate supply that is capable of an amp or so.

Hi,

have a look at the two links in my signature, they illustrate and suggest solutions to your problem

Duane B