-1

I decided to try out my servo on my Arduino. I'm pretty new to this and I can't seem to figure out why this is happening. My servo will spin for about 5 seconds in one direction and then it will spin the opposite way for less than a second and pause for about 3 seconds. This is the code I uploaded to my Arduino:

# include <Servo.h>
const int servopin = 8;
Servo servo;

void setup() {
  Serial.begin(9600);
  servo.attach(servopin);
  servo.write(0);
}

void loop() {
  servo.write(0);
  delay(5000);
  servo.write(180);
  delay(5000);
}

I believe the servo is a Tower Pro Micro Servo 99 (either 9 might be a g) SG90.

  • 2
    An RC hobby type servo which rotates more than a full rotation is either a continuous rotation or possibly "sail winch" model, not an ordinary one. Continuous rotation servos are typically made from ordinary servo chassis with the feedback potentiometer and associated stop removed, so they may be hard to visually distinguish by anything but model number and behavior. – Chris Stratton Dec 29 '17 at 4:40
  • 1
    pause for about 3 seconds ... and then what? – jsotola Dec 29 '17 at 4:46
  • 2
    you only tried 0 and 180 ? no experimenting of any kind?? – jsotola Dec 29 '17 at 4:47
  • 1
    How long does it take to spin 180º? – Nick Gammon Dec 29 '17 at 7:42
1

I might want to try decreasing the range, e.g. start from 10 instead of 0, or finish at 170 instead of 180. Here is an example:

# include <Servo.h>
const int servopin = 8;
Servo servo;

void setup() {
  Serial.begin(9600);
  servo.attach(servopin);
  servo.write(0);
}

void loop() {
  servo.write(10);
  delay(5000);
  servo.write(170);
  delay(5000);
}

After checking it works, try experimenting with different ranges to see how your servo reacts.

For me starting at 7 instead of 0 did the job.

1

When I am getting started with my Servo motor SG90, I have experience the same issue, and finally I have solved the issue. I have used external power supply for Servo and my Arduino with laptop USB port and control signal from Arduino to Servo motor make my Servo motor to spinning continuously.

Make sure ground reference of power supply of Servo motor and Arduino are same.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.