The brown wire is ground (-) and the middle one seems like orange or red that's (+) vcc and yellow or kind of orange that's for data/signal.
You can try the sketch below or get it from Arduino site.
#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(3); // attaches the servo on pin 3 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(5); // 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(5); // waits 15ms for the servo to reach the position } } |
Note: If you don't know what sg90 servo motor is, then her is a video for you to watch.
This was a very short post just to explain howto wire up the servo SG90 and a small testing sketch to try it out. I hope it helps you, if it does please don't forget to come back and leave comment. Thanks
No comments:
Post a Comment