What are the commands to run and rotate a servo and what pins can I use for it?
Servo test code. Have you read the servo information on the main arduino site?
// zoomkat 12-25-13 serial servo test
// type servo position 0 to 180 in serial monitor
// or for writeMicroseconds, use a value like 1500
// Send an a to attach servo or d to detach servo
// for IDE 1.0.5 and later
// Powering a servo from the arduino usually *DOES NOT WORK*.
#include <Servo.h>
String readString; //String captured from serial port
Servo myservo; // create servo object to control a servo
int n; //value to write to servo
void setup() {
Serial.begin(9600);
myservo.writeMicroseconds(1500); //set initial servo position if desired
myservo.attach(7, 500, 2500); //the pin for the servo control, and range if desired
Serial.println("servo all-in-one test code 12-25-13"); // so I can keep track of what is loaded
Serial.println();
}
void loop() {
while (Serial.available()) {
char c = Serial.read(); //gets one byte from serial buffer
readString += c; //makes the string readString
delay(2); //slow looping to allow buffer to fill with next character
}
if (readString.length() >0) {
Serial.println(readString); //so you can see the captured string
// attach or detach servo if desired
if (readString == "d") {
while (digitalRead(7)) {} //delay loop until pin 7 is low
myservo.detach(); //detach servo
Serial.println("servo detached");
goto bailout; //jump over writing to servo
}
if (readString == "a") {
myservo.attach(7); //reattach servo to pin 7
Serial.println("servo attached");
goto bailout;
}
n = readString.toInt(); //convert readString into a number
// auto select appropriate value
if(n >= 500)
{
Serial.print("writing Microseconds: ");
Serial.println(n);
myservo.writeMicroseconds(n);
}
else
{
Serial.print("writing Angle: ");
Serial.println(n);
myservo.write(n);
}
bailout: //reenter code loop
Serial.print("Last servo command position: ");
Serial.println(myservo.read());
Serial.println();
readString=""; //empty for next input
}
}
The commands: Servo - Arduino Reference
That page also covers how many servos you can run (12 on an UNO) and what pins you can use (any digital I/O pins).
You will need to provide roughly 1 Amp of 4-6V DC power per servo. This is more than you can get from the +5V pin of an Arduino UNO so expect to use a separate power source for the servos.
can a servo rotate 360°
Hi,
I think before we go any further.
What is your electronics, programming, arduino, hardware experience?
What do you want to do with the servo, and with what controller?
Tom...... ![]()
Well, look what Google gives me! https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=360+degree+servo&tbm=shop
Isaac96:
Well, look what Google gives me! https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=360+degree+servo&tbm=shop
Gives me "Server not found".
can a servo rotate 360°
Sail winch servos can rotate more than the typical 180 deg. of the standard RC servos. A "360 deg. servo" usually refers to a servo modified for continuous rotation and which cannot be commanded to a specific position.
johnwasser:
expect to use a separate power source for the servos.
Connected as shown attached.....

johnwasser:
you can use (any digital I/O pins).
Which includes the analog pins used as digital pins... I tested that a while ago.
Hi,
JimboZA you have tarted up your servo diagram. (its lost all its character)
Tom..... ![]()
TomGeorge:
Hi,
JimboZA you have tarted up your servo diagram. (its lost all its character)Tom.....
Ah crap, that's actually an older one in Eagle, I normally post the ExpressSCH one...