Can't stop SG90 spinning I have a SG90. I just want it to spin 360° and stop, that's about it. This seems impossible.
I have tried the sweep example:
 by BARRAGAN &lt;http://barraganstudio.com&gt;
 This example code is in the public domain.

 modified 8 Nov 2013
 by Scott Fitzgerald
 http://www.arduino.cc/en/Tutorial/Sweep
*/

#include &lt;Servo.h&gt;

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0;    // variable to store the servo position

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

void loop() {
  for (pos = 0; pos &lt;= 180; pos += 1) { // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
  for (pos = 180; pos &gt;= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
}


This works fine.
I read somewhere that for 360 motors the variable in myservo.write() is actually just the speed. So I tried:
void loop() {
    myservo.write(0);              // tell servo to go to position in variable 'pos'
    delay(2000);                       // waits 15ms for the servo to reach the position
    myservo.write(180);              // tell servo to go to position in variable 'pos'
    delay(2000);
    myservo.write(0);              // tell servo to go to position in variable 'pos'
}

The motor rotates several times then spins the other direction and repeats doing this.
What do I need to do to make it complete 1 rotation and stop?
TL;DR: Can't be done.
On a servo modified for continuous rotation, the signal you send sets direction and speed, not rotation angle. You can stop it, but you can't set an angle.
The sweep example will turn a continuous rotation servo in both directions, but I doubt it hits the angles you send it; it will just adjust speed and direction.
Without external hardware and feedback, like a limit switch, or a rotary encoder, there is no way of knowing what angle the servo is at, and no way to rotate to exactly 360° other than experimenting and &quot;guessing&quot; based on time and rotation speed.
You can then stop it by setting it to the PWM value for 90° or center position, which should set the rotation speed to 0.
On a servo, you can't have both continuous rotation with a set speed, and a set angle of rotation, without extra hardware.
Maybe a stepper motor would be a better choice for your application, or a &quot;normal&quot; servo with a gear that gives you the required rotation range.