Detaching Servos

Hi, I’m trying to make a servo move to a specific position and then “detach” it, so it stops buzzing once it’s done moving.

Below is my code. The problem is that the servo won’t move at all with “myservo.detach();” in the code. If I remove “myservo.detach();”, the servo will move, but will still buzz. Any help is much appreciated!!

#include <Servo.h>
int pos = 0;
Servo myservo;

void loop (){}

void setup()

{

myservo.attach(9);
myservo.write(pos);
delay(1);
myservo.detach();

}

You are not giving the servo time to move to the commanded angle. As an experiment increase the delay and see what happens.

The servo should not buzz when in a commanded position. It sounds like something attached to the servo is trying to move it and the servo is resisting. If that is the case then when you detach() the servo it will no longer try to hold its position and may move.

I changed the delay to 10000 and included the detach(), but the servo still buzzes after 10 seconds.

Now I also have a new problem. I get the following error message when I upload a sketch:

Binary sketch size: 3,574 bytes (of a 258,048 byte maximum)
avrdude: verification error, first mismatch at byte 0x0000
0x02 != 0x14
avrdude: verification error; content mismatch