Pages: [1]   Go Down
Author Topic: Can't get servo to work  (Read 1070 times)
0 Members and 1 Guest are viewing this topic.
Germany
Offline Offline
Newbie
*
Karma: 1
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Guys!

At first: The Arduino is awesome. I just love it! I got mine yesterday. I bought a servo too, it's a SpringRC SM-S430R.

I Can't get it to work.

I saw a topic here in this forum, but I can't find it anymore.
Well - The Servo stops at 1500. 0-1500 is CCW, 1500+ is CW.

I found this script in the post:

Code:
#include <Servo.h>

Servo myservo;

void setup()
{
  myservo.attach(9); //set up the servo as usual
  Serial.begin(9600); //for watching the speeds in the serial monitor
}

void loop() {

// on this servo 1500 is stopped, above 1500 is clockwise, below is counter clockwise

     for (int i=1500; i >= 1300; i=i-20) //start from a stop and slowly increase to get the motor turning
     {
      myservo.writeMicroseconds(i);
        Serial.print("Running motor at: ");
        Serial.println(i, DEC);
      delay(5000);
   }
 
       for (int i=1300; i <= 1500; i=i+50)
     {
      myservo.writeMicroseconds(i);
        Serial.print("Running motor at: ");
        Serial.println(i, DEC);
      delay(5000);
   }
 
   delay(5000); //wait for five seconds and then spin it the other way, counting up again.
 
    for (int i=1500; i <= 1700; i=i+20)
     {
      myservo.writeMicroseconds(i);
        Serial.print("Running motor at: ");
        Serial.println(i, DEC);
      delay(5000);
   }

}

But when I connect my servo and upload this script to my Arduino Uno (rev3), I just hear a buzzing noise coming from the Servo.
I made some adjustments yesterday, I changed some values - then the servo worked fine. But today, I can't remember these adjustments, and it doesn't matter what I do (changing the power Value from 1500 to 3000 for an example), the servo just doesn't move and its just this annoying buzzing noise. As I said, the servo worked fine yesterday.

Any suggestions?

Im very confused.

Thanks smiley
Logged

If Chuck Norris sees a Antilope driving a car, it's NOT Chuck Testa.

0
Offline Offline
Tesla Member
***
Karma: 145
Posts: 9698
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How are you powering your servo?
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Germany
Offline Offline
Newbie
*
Karma: 1
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

the servo is connected to 5V, GND and Pin 9.

I just plugged three Jumper Wires into the female connector.
Logged

If Chuck Norris sees a Antilope driving a car, it's NOT Chuck Testa.

0
Offline Offline
Tesla Member
***
Karma: 145
Posts: 9698
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Generally trying to power a servo from an arduino is not a good idea. Below is some servo test code.

Code:
// zoomkat 10-14-11 serial servo test
// use a microseconds value like 1500 in serial monitor
// 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"); // 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);  // allow buffer to fill with next character
    }

  if (readString.length() >0) {
    Serial.println(readString);  //so you can see the captured string
    myservo.writeMicroseconds(readString.toInt()); //convert readString to number for servo
    readString=""; //empty for next input
  }
}

Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Hyderabad, India.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 98
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

is the servo vibrating which is the cause of the buzzing noise???
Logged

Germany
Offline Offline
Newbie
*
Karma: 1
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you Zoomkat, I will give it a try.

@kirti:

Yes, the Servo buzzes because the motor works or is powered, but the power level is too low, allthough I changed the power values.
Logged

If Chuck Norris sees a Antilope driving a car, it's NOT Chuck Testa.

Pages: [1]   Go Up
Jump to: