Search code examples
arduinoservo

Arduino Tower Pro SG90 Continuous rotation servo Control


I have Hacked Tower SG90 for continuous rotation. I can control it for forward and backward motion. But I don't know how to stop the servo. I am using arduino nano to control Servo. Here is my code :

#include <Servo.h> 
Servo myservo;  // create servo object to control a servo 

void setup() {
  myservo.attach(14);
}

void loop() {
  myservo.write(0); // for forward motion
  delay(1000);
  myservo.write(180); // for backward motion
  delay(1000);
}

Solution

  • myservo.write(90)
    

    From Arduino Documentation

    Writes a value to the servo, controlling the shaft accordingly. On a standard servo, this will set the angle of the shaft (in degrees), moving the shaft to that orientation. On a continuous rotation servo, this will set the speed of the servo (with 0 being full-speed in one direction, 180 being full speed in the other, and a value near 90 being no movement).