I got my sg90 servo today and I wanted to try it. First I connected the + pin on servo from 5v of my nano. It didn't work, then I connected it from breadboard power supply and it moved a bit, but after that no response! is it broken?
Even those tiny servos draw more current than can safely be supplied by the 5V pin of a microcontroller, although I do sometimes do it for a test. So it's not something to be encouraged. Use a separate supply.
And post the code; maybe there's something wrong there too.
I agree with the suggestions above. However it's more likely you have a code or wiring error. I'm assuming you did connect the signal wire and just forgot to mention it?
Your SG90 Servo Motor has the following colored wires. Check that you have connected the servo accordingly with UNO.
Figure-1:
Figure-2:
Test Sketch
Ever time you press K1 of Fig-2, the servo will move by 30 degrees.
Write codes and post here which will be corrected by the Forum Members if needed.
[code]
#include <Servo.h>
/* After including the corresponding libraries,
we can use the "class" like "Servo" created by the developer for us.
We can use the functions and variables created in the libraries by creating
objects like the following "myservo" to refer to the members in ".".*/
Servo myservo;
//it created an object called myservo.
/* you can see Servo as a complex date type(Including functions and various data types)
and see myservo as variables. */
void setup(){
/*"attach" and "write" are both functions,
and they are members contained in the complex structure of "Servo".
We can only use them if we create the object "myservo" for the complex structure of "Servo".
*/
myservo.attach(9);//connect pin 9 with the control line(the middle line of Servo)
myservo.write(90);// move servos to center position -> 90°
}
void loop(){
myservo.write(90);// move servos to center position -> 90°
delay(1000);
myservo.write(60);// move servos to center position -> 60°
delay(1000);
myservo.write(90);// move servos to center position -> 90°
delay(1000);
myservo.write(150);// move servos to center position -> 120°
delay(1000);
}
[/code]