servo motor that came with arduino kit not working

hey guys,

I bought the beginner’s UNO kit a week ago, everything is working just fine I am currently working on the project Mood-cue where I control a servo motor using a potentiometer but it is not working at all I tried everything from changing the code to changing the power source.

so I tried the sweep example that comes built-in with the program but is in not working neither, and I don’t think Arduino will send me a bad motor.

so if you can take a look at the code maybe they changed the Servo library or something.

and for the connections I am pretty nothing is wrong the white wire to PWM pin 9 black wire to ground and the red wire to 5 volts and I tried a 9v battery but nothing is working.

thanks.

/* Sweep
 by BARRAGAN <http://barraganstudio.com>
 This example code is in the public domain.

 modified 8 Nov 2013
 by Scott Fitzgerald
 http://www.arduino.cc/en/Tutorial/Sweep
*/

#include <Servo.h>

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

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 += 1) { // 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(15);                       // waits 15ms for the servo to reach the position
  }
  for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
}

It’s generally not a good idea to power servos from the Arduino 5V pin but you usually get away with it with one small servo like the 9g type included in most kits.

That Sweep code has worked for thousands of people (and servos) and nothing has changed. So either the servo or your wiring are bad. Wires can sometimes make bad contact or even be broken inside the insulation. Also those servos are very cheap so there’s not much quality control involved. It’s not unknown for one to be dead on arrival!

OTOH if you have put 9V directly into the servo (rated for 5V) then it’s quite possible you now have a dead servo.

Steve

so what is the best servo for these projects?

and how much voltage exactly does it need?

thanks!

abdelrahman0393:
so what is the best servo for these projects?

and how much voltage exactly does it need?

The 9g sized servo should be fine. Most of them work in the voltage range 4.5v to 6v.

The simplest way to check if your servo is broken is to get another one for comparison.

...R

For playing about , any cheap small servo will do the job .

As said if you have connected it to 9v , it’s probably dead .

Don’t connect a servo to Arduino 5V, use a separate supply rated at 1 amp or more. And common the grounds.

That’s the first thing to get right, as power supply issues are 95% of problems people have who are new to
hobby servos.