I'm quite new to Arduino programming but I thought I would experiment a little with a smaller SG90 servo engine. As I understand it will suffice to connect red to + 5v and brown to GND and them orange signal cable to a digital pin in this case 9 and then run example sketch (code) for servo sweep.
But unfortunately nothing happens ... The only movement I get from the motor is a little jerk when + and GND are connected. Have tested with external power to the motor, together with another Arduino UNO card but stil no movement.
I have also tried running the code without using the Servo.h library and instead specified the milliseconds for the pulse accordingly to the specification for the servo motor.
I tried with 3 different kind of SG90 motors with the same result.
Starting to get very frustrated since this shouldent be this hard according to the tutorials i found online.
Some pictures of my setup with external power (6v measured on the motor connector)connected to the motor.
Your circuit looks o.k. and generally a single SG90 will be fine even if you run it from the Arduino 5V pin (though it's not really good practice). And the basic Sweep example code works for thousands of us with no problems. You could try a different digital pin just in case pin 9 is bad.
Otherwise I don't really know what to suggest. Either your connections via the breadboard are bad or you have managed to get several bad servos (are they all from the same supplier?). I notice that they're not genuine TowerPro SG90s but there are plenty of cheap clones around that seem to work o.k.
Ignore the above advice. You can actually destroy an Arduino by running a servo or motor from the 5V pin, as they sometimes inject high voltage spikes into the leads.
Never attempt to power anything with a coil from the 5V regulated output.
jremington:
Ignore the above advice. You can actually destroy an Arduino by running a servo or motor from the 5V pin, as they sometimes inject high voltage spikes into the leads.
Never attempt to power anything with a coil from the 5V regulated output.
I guess I've just been lucky with the many times I've tested code running a single SG90 servo on several different Arduinos.
Just for interest have you actually seen any Arduinos "destroyed" by an SG90 or similar low-powered micro servo on the 5V pin? I've heard many dire warnings but I don't recall ever hearing of an actual problem.
I've destroyed quite a number of Arduinos by making faulty connections, but I have yet to make the ill advised mistake of overloading the 5V output by connecting servos or motors to it.
The scope traces showing 20 V spikes on the power leads of one servo were enough to convince me that doing so should NEVER be recommended to anyone.
jremington:
I've destroyed quite a number of Arduinos by making faulty connections, but I have yet to make the ill advised mistake of overloading the 5V output by connecting servos or motors to it.
So that's a no then?
While "Do not in general power random servos and motors via the 5V pin" (or for that matter via a breadboard) is excellent advice. in the specific case all the experimental evidence seems to suggest that SG90 and similar size servos, as used in just about every Arduino starter kit, are actually reasonably safe.
I have about 20 pcs of SG90 micro servro motors clones from from china So there is no problem testing with another motor, but since I already tested with 3 of the china servos and 2 other brands and 2 different ardunio boards and still has the same problem, I don´t think its the hardware fault.
The servo motor is connected to external power 6v.
I also tested switching to another pin instead of 9, but is there any way to troubleshot the pulse signal?
The code is the sweeper exampel code only with som mods to the timing:
#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(13); // 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(30); // waits 30ms 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(30); // waits 30ms for the servo to reach the position
}
}
I have set up another ardunio unit the check the pulse signal. I have connected pin 13 on the first unit to pin 3 on the secound one. With the following code running on ardunio nr 2: