servo motor problem

Hi all!

I'm quite new to the arduino UNO board, but i've already experimented the basic stuff (leds and so on). Now i'm tryin to use a servo motor (the blue bird bms-371), following various tutorial and using the example provided with arduino itself (the sweep example).
I'm writing here 'cause i cannot get it working... Wired the red to the +5V on arduino, the brown to the GND e the orange to pin 9. Nothing appens. The same if the arduino board is powered via regulated dc wall adaptor. The only "movement" that i've been able to get appens when i disconnect and reconnect the +5V. In this case there is a little movement (say 5°).

What i'm doing wrong?

Thanks!

What i'm doing wrong?

I don't know as you haven't given anything to go on like a photo of what your setup is, or the code that you are trying to use. (use the # icon when posting).

Appen then something will happen.

Wired the red to the +5V on arduino

This is probably your problem. You generally can not power a servo or motor directly from an arduino. You need to use an external power supply.

I've gone not too deep in details because i've followed the tutorial proposed in the arduino servo library reference. This one: http://arduino.cc/en/Tutorial/Sweep to be precise.
Same code and same circuit.

Same code and same circuit.

Is it working for you? The below from the tutorial is generally bad info on powering a servo. Servos can use more power than can be supplied from a USB port.

The power wire is typically red, and should be connected to the 5V pin on the Arduino board.

This is probably your problem. You generally can not power a servo or motor directly from an arduino. You need to use an external power supply.

To do much meaningful work with a decent sized servo or run multiples I agree. But to run the sweep example I disagree. I have run steering servos while the Arduino was powered by USB many times out of convenience to adjust trim. I looked up that servo and it is 4.8v analog and should work fine unloaded. As far as wires go, I see some odd color choices in pictures. The +5 is always the center wire (except Airtronics!) and the darker of the two outside wires should be ground.

Do you have a servo tester?

Is it working for you?

No, it's not working. That's why i'm posting here...

Servos can use more power than can be supplied from a USB port.

Yes, i know. So i've tried powering the arduino board from a wall adapter, suppling 6 volts and up to 1amp (from his specs).
So, for what i know, it should'n be a powering problem.

Do you have a servo tester?

No, i don't have one. But i've tried with two different servos, one of which as been reported to me as working (was used in a car model).

Yes, i know. So i've tried powering the arduino board from a wall adapter, suppling 6 volts and up to 1amp (from his specs).
So, for what i know, it should'n be a powering problem.

If you are powering the arduino from the wallwart via the arduino external power connector, this could be an issue, as the external connector usually requires something like 7v minimum for the power regulator chip to supply 5v to the board. You need to connect the servo red wire directly to the wallwart 6v, and have a common ground between the wallwart and the arduino board. If that doesn't work, then there are probably other issues that are in play.

Really - your answer will come a lot quicker if you post your code, post pictures of your setup, perhaps an image of your schematic.

You can tell us all you want that you are using the example - but that ultimately tells us nothing, because we don't know for certain whether you hooked it up properly, etc. For all we know, your breadboard may be the culprit!

Please - show us the circuit and the code!

:slight_smile:

Try a different pin in the PWM range that you haven't used in any other tutorials. Just change the pin number in the code to match.

EDIT - Just saw the kat's catch on your 6v wall wart. He is right; you need to go to something higher.

if you post your code, post pictures of your setup, perhaps an image of your schematic.

Ok. Here's the code:

#include <Servo.h> 
 
Servo myservo;  // create servo object to control a servo 
                // a maximum of eight servo objects can be created 
 
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 < 180; pos += 10)  // 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(50);                       // waits 15ms for the servo to reach the position 
  } 
  for(pos = 180; pos>=1; pos-=10)     // goes from 180 degrees to 0 degrees 
  {                                
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(50);                       // waits 15ms for the servo to reach the position 
  }
}

Two little changes from the base example:
incremented delay (from 15 to 50 ms) and modified step size from 1 to 10 in for loop (obviously i've tried with the values in the example too)
And here's a picture of the whole:

Have you tried it powered by USB?
No it isn't good practice in general, but it should have 5v on the 5v line that way (with 6v wall wart going through a VR, it's a different story).

Have you tried it powered by USB?

Yes, i've tried with both: via USB and via wallwart

If the below is your servo, then its small size should allow it to possibly do some unloaded movement using the arduino 5v source (it is speced for 4.8v and I saw a post saying to not use 6v). Below is some simple servo test code I use that might be of use looking for your problem.

http://www.hobbycity.com/hobbycity/store/uh_viewItem.asp?idProduct=9444

// zoomkat 10-4-10 serial servo test
// type servo position 0 to 180 in serial monitor
// for writeMicroseconds, use a value like 1500
// for IDE 0019 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.attach(7);  //the pin for the servo control 
  Serial.println("servo-test-21"); // so I can keep track of what is loaded
}

void loop() {

  while (Serial.available()) {
    delay(10);  
    if (Serial.available() >0) {
      char c = Serial.read();  //gets one byte from serial buffer
      readString += c; //makes the string readString
    } 
  }

  if (readString.length() >0) {
    Serial.println(readString);  //so you can see the captured string 
    int n;
    char carray[6]; //converting string to number
    readString.toCharArray(carray, sizeof(carray));
    n = atoi(carray); 
    myservo.writeMicroseconds(n); // for microseconds
    //myservo.write(n); //for degees 0-180
    readString="";
  } 
}

http://www.hobbycity.com/hobbycity/store/uh_viewItem.asp?idProduct=9444

yes, this is the servo i'm trying and... with the code you've provided works perfectly! With both method:
writeMicroseconds() and write()
This is a little strange... seems to me that the only difference with the code shipped as example with servo library is the delay() in the for loop. Could this be the problem? I'll make some try and keep you informed. Thanks for the help!