[SOLVED]: Servo problem (power supply?)

I just got my Arduino Uno R3 today and I was going through the tutorials that came with the kit. I tried the servo one and it doesn't seem to work. I used company provided code for testing.

The servo is a Tower Pro Micro servo 9g SG90. When hooked up exactly as the tutorial goes with their programming it seems to attempt what it's supposed to do. (Turn 90 then 180 and so on...) I can hear internal clicking but I get no external movement. Is it broken or is it underpowered or something else? It's hooked up to the 5 V pin from the Arduino.

Thanks!

Hi spyro,

Did you connect the grounds?

You should try the servo exams on this site first... At least we'll know the code is OK.

Also, if that doesn't work, try connecting the servo to its own 3v-6v battery (and connect the grounds). Sometimes there isn't enough current for both, although usually the symptom is that the Arduino reboots.

Pat.

Servos normally use a lot of power, lots more than the arduino, or usb will provide. Yes, sounds like you need an external supply. The signal pin is low power, but the ground and plus use a lot of current.

Thanks for the replies, and sorry it took a week to get back on. I had work and a bunch of stuff come up. Grounds are properly connected. In any case what exams are you referring to?

Code being used:

#include <Servo.h> // servo library

Servo servo1; // servo control object

void setup()
{
servo1.attach(9);
}

void loop()
{
int position;
servo1.write(90); // Tell servo to go to 90 degrees

delay(1000); // Pause to get it time to move

servo1.write(180); // Tell servo to go to 180 degrees

delay(1000); // Pause to get it time to move

servo1.write(0); // Tell servo to go to 0 degrees

delay(1000); // Pause to get it time to move

for(position = 0; position < 180; position += 2)
{
servo1.write(position); // Move to next position
delay(20); // Short pause to allow it to move
}

for(position = 180; position >= 0; position -= 1)
{
servo1.write(position); // Move to next position
delay(20); // Short pause to allow it to move
}
}

I deleted out as many comments as I could in the short time I have. I think I only deleted comments.

The code looks good to me. Compiles fine. The only thing I find atypical is position += 2, etc. Typically I would use position++ but I program primarily in Java and I believe Arduino is a variant of C?

Furthermore is there a tutorial that I overlooked on how to add an external source of power to a component? I think I know what I'm doing but if I'm not doing something right it could just as easily be that.

See attachment for circuit diagram I'm provided. In case of blurriness: 5V from Arduino to breadboard power, GND to breadboard ground. From the same side of the H-bridge as power/ground: Power to A6, Ground to B5, ~9 on Arduino to A6, E5, 6, 7 to Servo brown, pink, orange (or black gnd, red power, white control[?]) respectively.

I still think the servo is using more power than the arduino can provide, especially when you tell it to move a long way (like from pos 180, to pos 0). Try comment the code that moves far distances, and use just the for loops. (short steps). That still could be a problem since we don't know where (what position) the servo is to start with, so it may still be a far way to go just to get to the codes starting position.
Do you have a URL to the specs on that servo? Let us see that.
Got an extra power supply, to run the servo from?
Got any extra capacitors you can add to the servo ground/5v ?

I don't have any sort of official power supply, just batteries mostly. I have a 4 AA battery holder with loose ends that fit my breadboard if that would work?

I have a variant of this package. Apparently Amazon edited my order history because it isn't the same, but similar. My board is actually an Arduino Uno R3.

The only capacitor I currently have immediate access to is a 1000 micro F 16 V out of an old power supply for a PC. I may be able to pull off a larger or smaller one as well but they haven't come off the PSU nicely and I have no idea of their condition in terms of worthiness.

The code does work. I added Serial print statements and it runs through every line in both for loops. Still no movement though. I'm thinking it's just broke.

Ok, great, 4AA batteries should power the servo fine (if they are charged). LOL
So, hook the 4AA (power pack) to the ground and +5 of the servo.
Hook the ground of the servo to the ground of the arduino.
Hook the control of the servo to the pin on the arduino that you are sending out the servo controls.
Forget about the capacitors for now.
Run the program. Good luck. If yes or no, let us know.

Jack

Typical servo wiring setup.

jackwp:
Ok, great, 4AA batteries should power the servo fine (if they are charged). LOL
So, hook the 4AA (power pack) to the ground and +5 of the servo.
Hook the ground of the servo to the ground of the arduino.
Hook the control of the servo to the pin on the arduino that you are sending out the servo controls.
Forget about the capacitors for now.
Run the program. Good luck. If yes or no, let us know.

Jack

Thanks! That did the trick. It's quite touchy though. I think the ground pin on the servo might be damaged because it seems to need wiggling sometimes.

Glad to hear it is working. If that solves the problem, please go back to your first post, and modify the subject to include (SOLVED). That will allow others with similar problems to find solutions.

Thanks, Jack