HELP! Servo keeps running (with just attach() method)!!

Hi,

I am afraid my micro servo might be broken, but I wanted to confirm it by asking you guys a question.

I was building a very simple project - push a button and servo turns 180-degrees - for my kid's school project. I got it to work, but while I turned around for like 5 minutes, my kid did something with the board and now servo keeps turning.

I took the pushbutton out and tried putting servo in different digital pins, and it didn't make a difference. I also tried to isolate the problem by commenting out most of the code. Even with just attach() method, it makes the servo keep turning...... I am afraid my servo is somehow busted.... :frowning:

Can someone tell me if I am doing something obviously wrong? I really appreciate your help in advance!!!

Board setup:
Uno 5V to breadboard +
Uno GND to breadboard -
Servo (Hitec 31055S HS-55) red cable to breadboard +
Servo black cable to breadboard -
Servo yellow cable to Uno digital pin #12

Code:

#include <Servo.h> 
 
//int buttonPin = 7;  
int servoPin = 12;
 
Servo servo;  
int angle = 0;   // servo position in degrees 
 
void setup() 
{ 
  servo.attach(servoPin); 
//  pinMode(buttonPin, INPUT);
} 

void loop() 
{ 
//  val = digitalRead(buttonPin);
//  if (val == HIGH) {
//    servo.write(180);
//    delay(3000);
//    servo.write(0);
//  }
}

Do you have a link to the Servo you purchased? Sounds like you bought a continuous rotation servo.

codlink:
Do you have a link to the Servo you purchased? Sounds like you bought a continuous rotation servo.

Here is the servo I bought. http://www.amazon.com/gp/product/B0006O3WNW/ref=oh_details_o00_s01_i00?ie=UTF8&psc=1

No, I had it work to go from 0 to 180, and back to 0.... But somehow after my kid did something, it just started to turn endlessly.... :frowning:

Sounds like you bought a continuous rotation servo.

But that wouldn't explain why it was working, and now it's not....

A way to test that would be to send it to position 90, which if I understand things correctly is 0 speed on a continuous servo, with position 0 being max speed one way and 180 being max speed the other. (Although from what I read here it's not always 90 exactly, try values either side.)

Your 0 would indeed be sending it off in circles if it's a continuous servo.

JimboZA:
A way to test that would be to send it to position 90, which if I understand things correctly is 0 speed on a continuous servo, with position 0 being max speed one way and 180 being max speed the other. (Although from what I read here it's not always 90 exactly, try values either side.)

Your 0 would indeed be sending it off in circles if it's a continuous servo.

I can't even do that because as soon as I connect signal wire, it starts turning....

I can't even do that because as soon as I connect signal wire, it starts turning....

Oh yeah, my bad...

I can't think what the problem might be- something mechanical probably... if your son perhaps wrenched the horn past one of the end stops could that have done this?- I don't know. (I do know that one of the mods you need to make to a normal servo to make it continuous is remove the end stops.)

Servo test code.

// zoomkat 10-22-11 serial servo test
// type servo position 0 to 180 in serial monitor
// or for writeMicroseconds, use a value like 1500
// for IDE 0022 and later
// Powering a servo from the arduino usually *DOES NOT WORK*.

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

void setup() {
  Serial.begin(9600);
  myservo.writeMicroseconds(1500); //set initial servo position if desired
  myservo.attach(7);  //the pin for the servo control 
  Serial.println("servo-test-22-dual-input"); // so I can keep track of what is loaded
}

void loop() {
  while (Serial.available()) {
    char c = Serial.read();  //gets one byte from serial buffer
    readString += c; //makes the string readString
    delay(2);  //slow looping to allow buffer to fill with next character
  }

  if (readString.length() >0) {
    Serial.println(readString);  //so you can see the captured string 
    int n = readString.toInt();  //convert readString into a number

    // auto select appropriate value, copied from someone elses code.
    if(n >= 500)
    {
      Serial.print("writing Microseconds: ");
      Serial.println(n);
      myservo.writeMicroseconds(n);
    }
    else
    {   
      Serial.print("writing Angle: ");
      Serial.println(n);
      myservo.write(n);
    }

    readString=""; //empty for next input
  } 
}

Uno 5V to breadboard +

Your running it off the arduino 5V line? Servos usually need 6V to work properly.

No, I had it work to go from 0 to 180, and back to 0.... But somehow after my kid did something, it just started to turn endlessly....

He might have broken the pot inside the servo, and it is trying to set itself back to center. Some servos are setup to when you apply power to the signal wire, it automatically rotates and centers the servo. If the pot is broken, it will never be able to find center.

ok, let's back up. Connecting just the positive supply and ground to your servo, does it do anything?

Is it only when the signal pin is connected, or only when the servo.attach function is called?

now servo keeps turning.

I don't understand what this means. Just keep rotating forever?

If it's a regular servo, and not a continuous rotation servo, then it sounds like the servo
horn got twisted past its mechanical stop, and the stop broke off, and the internal
potentiometer is damaged - as in having the wiper torn off too.

You cannot power a servo from arduino directly. A servo may drain 0.8A when actuating.. You need a separate power source for a servo..

With all due respect to those saying he can't power it off the arduino... clearly he can because he claims that it was working. His problem is that the motor constantly is running, not that it isn't running at all. So, apparently he CAN run it off the arduino directly (unless he made a mistake in describing how he is powering it.) Definitely not advisable, but completely irrelevant to the problem that he is having.

Perhaps he is actually powering the breadboard with a beefier supply and also running the arduino from that? But, still, irrelevant to his problem.