Servos not responding to Arduino - Please help

Hello,

This is my first time posting, so please feel free to provide feedback on the post itself while expertly providing the advice that I need to get my servo working. I began by successfully hooking up the servos, and tinkering with them in an attempt to reduce noise that was causing jittering; but at some point they no longer worked on my system no matter how I adjusted it.

I did not provide a schematic as I've simplified my circuit, and my servo is simply wired to power supply (5V). I've tried both an independent power supply as well as using the 5V and ground pins on the Arduino (I've read that this is not recommended). I've also changed the wires and the microcontroller (Uno and Mega) all with the same result - servo sits there silently mocking me. I've also changed servos to no avail (both the SG90 and the MG996R).

Below is the simple code that I used, but I also tested using the example servo code as well (also below). Serial data from the first code is as it should be if the servo was operational (printing the desired response). I've also changed pins multiple times as I tested, making sure to use the correct pin for the code. Any help would be greatly appreciated as I've been beating my head against the desk for hours now!

Code #1

#include <Servo.h>
Servo myservo1;

void setup(){
  myservo1.attach(3);
  myservo1.write(90);// move servos to center position -> 90°
  Serial.begin (9600);
} 
void loop(){
  myservo1.write(30);// move servos to center position -> 60°
  delay(800);
  Serial.println ("Servo 1 - Move 1");
  
  myservo1.write(150);// move servos to center position -> 120°
  delay(800);
  Serial.println ("Servo 1 - Move 2");


}


 // myservo.write(30);// move servos to center position -> 60°
 // delay(500);
//  myservo.write(90);// move servos to center position -> 90°
//  delay(500);
//  myservo.write(150);// move servos to center position -> 120°
//  delay(500);

Code #2

#include <Servo.h>

Servo myservo;

void setup(){
  myservo.attach(10);
  myservo.write(90);// move servos to center position -> 90°
} 
void loop(){
  myservo.write(90);// move servos to center position -> 90°
  delay(500);
  myservo.write(30);// move servos to center position -> 60°
  delay(500);
  myservo.write(90);// move servos to center position -> 90°
  delay(500);
  myservo.write(150);// move servos to center position -> 120°
  delay(500);
}

When you use the external power for servo motor, did you connect GND of the external power source to Arduino GND ?

It sounds like you're doing everything right. There's nothing wrong with the codes that I can see. So if an SG90 connected to the 5V and GND pins on a Uno doesn't work then it's a hardware problem. Either the 5V pin isn't actually supplying 5V , the servo is dead or the wiring is bad.

Are you connecting these up via a breadboard because the connections in those can go bad particularly if you've been running relatively high currents,e.g. an MG996R, through them. Try moving all the connections and/or checking continuity with a DMM.

And maybe post a photo of your setup with SG90 and Uno, no external supply, just in case there's anything we can spot.

Steve

Don't use Arduino 5V to power motors or servos, its asking for touble, expensive trouble, and it usually
cannot work because servos need a lot more current than Arduino 5V can provide.

Even the smallest servos may need 1A, larger servos much more.

It's true that in general using the 5V pin for servo power is a bad idea but a single SG90 (stall current 650mA) is normally fine unless it is very highly loaded. More servos or a single larger servo may fail or even cause damage to the Arduino.

Steve

1 Like

a single SG90 (stall current 650mA) is normally fine unless it is very highly loaded.

No, it is not, especially if the Uno is powered by around 12V through the regulator. The regulator will INSTANTLY overheat.

Please do not give such bad and unprofessional advice on the forum.

@OP: You are advised by two forum members not to follow slipstick's advice. If you do, you may damage your Arduino.

SOLVED--

As I was reading your comments and writing this reply I went back and took a good look at the hardware. I've got it working now. The culprit was a bad servo and a bad wire. As I was trying different combos, 1 or the other would fail.

Also, I was having trouble before that with using an outside power source, and the common ground suggestion solved that one.

Thanks for the help and direction!

jremington:
No, it is not, especially if the Uno is powered by around 12V through the regulator. The regulator will INSTANTLY overheat.

That statement is simply not true. It hasn't been true for any of my Arduinos when I've done quick tests that way (wouldn't dream of doing it for a finished project) and it has obviously not been true for the hundreds of people who have successfully used the many starter kits and their example projects.

It certainly is a good idea to use an external supply for all servos and motors and it's essential in most cases. In the same fashion it is a really bad idea ever to power Arduinos from 12V if you have ANY peripherals connected to the 5V pin. I'd worry more about using 12V than I would about powering one micro servo which, I repeat, normally works perfectly well, particularly if the Uno is powered via USB.

Steve

1 Like

(wouldn't dream of doing it for a finished project)

So say that every time you post such utter nonsense.

Because you were lucky a couple of times, you mislead countless ignorant new forum members into destroying their equipment? What a great attitude!

jremington:
Because you were lucky a couple of times, you mislead countless ignorant new forum members into destroying their equipment? What a great attitude!

That's "lucky several dozen times". And I did notice your selective editing of my original post that removed all the warnings and caveats that I had included in it. I guess if you're determined to be rude and ignorant you're not to let little things like that put you off.

Steve

1 Like

slipstick:
It's true that in general using the 5V pin for servo power is a bad idea but a single SG90 (stall current 650mA) is normally fine unless it is very highly loaded. More servos or a single larger servo may fail or even cause damage to the Arduino.

Steve

650mA is more than a USB port can provide, so this will reset the Arduino randomly (if
you read the posts here you know this happens all the time to people)

Budget at least an amp for a small servo, use separate power, then you don't need to worry!