Go Down

Topic: Arduino Uno - which pin can control servos? (Read 8 times) previous topic - next topic

primate

Folks, just hooked up my servo on pin 16 (Analog pin 3 on my UNO), hooked up the servo library with a few lines of code and it just worked! Thanks for the advice.

BigGuyWhoKills


Quote
I've seeon other examples that seem to suggest that any output pin (PWM or not) can be used to control a servo

Any pin can be used to command a servo.


Can analog pins be used for servos?

Also, the SainSmart Sensor Shield v4 says it has 13 ports that can be used, but the digital ports are numbered from 0 to 13, for a total of 14.  Is pin 0 an input-only port?

At the risk of taking over this thread, I have three more questions:
1. Do digital servos need to be handled differently than analog servos?
2. Does an electronic speed controller need to be handled differently than servos?
3. And lastly, is there better documentation somewhere that I can reference so that I don't need to bother you fine people?

AWOL

Quote
Can analog pins be used for servos?

Yes
Quote
1. Do digital servos need to be handled differently than analog servos?
2. Does an electronic speed controller need to be handled differently than servos?
3. And lastly, is there better documentation somewhere that I can reference so that I don't need to bother you fine people?

No,
No,
Don't know
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.


BugZapp

I am starting on a new project to create a walking robot using 3 servos, i read Zoomcat's code and changed it is this corect im sort of new to coding arduino

#include <Servo.h>
String readString, servo1, servo2, servo3;
Servo myservo1;
Servo myservo2;
Servo myservo3;

void setup() {
  Serial.begin(9600);
  myservo1.attach(6); 
  myservo2.attach(7);
  myservo3.attach(8);
  Serial.println("three-servo-test-1.0");
}

void loop() {

  while (Serial.available()) {
    delay(3);   
    if (Serial.available() >0) {
      char c = Serial.read(); 
      readString += c;
    }
  }

  if (readString.length() >0) {
      Serial.println(readString);

      servo1 = readString.substring(0, 4);
      servo2 = readString.substring(4, 8)
      servo3 = readString.substring(8, 12);

      Serial.println(servo1); 
      Serial.println(servo2);
      Serial.println(servo3);

      int n1 = servo1.toInt();
      int n2 = servo2.toInt();
      int n2 = servo3.toInt();
     
      myservo1.writeMicroseconds(n1); 
      myservo2.writeMicroseconds(n2);
      myservo3.writeMicroseconds(n2);
    readString="";
  }
}

Go Up