Most people seem to recommend to use pin 9 and 10 to control the servo for arduino Unos.
I am trying to attach a servo on an Arduino (branded) Robot but not sure which pin to use for the bellow code.
I have tried attaching it to the TKD analogue pin and also D3 digital pin,however, "myservo.attach()" seems to not take these values.
Thanks,
-M
I have been referencing this for the Control board pin mapping:
Example Servo Code from Arduino website:
#include <Servo.h>
Servo myservo; // create servo object to control a servo
int pos = 0;
void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop()
{
for(pos = 0; pos < 60; pos += 1)
{
myservo.write(pos);
delay(15);
}
for(pos = 60; pos>=1; pos-=1)
{
myservo.write(pos);
delay(15);
}
}
From reading the documentation (http://arduino.cc/en/Main/Robot) I think that TKD0-TKD3 can be use for servos by calling them pins 19-22. You can't use Pin 9 because that is already used as the Slave Select pin for the LCD.
Thanks for the reply. I'm working with mimas and we're still having issues in getting this servo to run.
We've tried altering the code by changing the pin specified to 19 and plugging the servo in. We didn't get a result so we tried with pins through 19-22.
I have checked the wiring layout but I believe it's correct.
Is there anything else we have missed? Is declaring pinMode necessary?
You should be able to use any of the following designations:
19 == A1 == TKD0
20 == A2 == TKD1
21 == A3 == TKD2
22 == A4 == TKD3
Each of those four locations on the board have three holes. I assume one hole is Ground (Servo Black), one is Vcc (Servo Red), and one is Signal (Servo White or Yellow). I don't think you need to use pinMode() on those pins if you use them with the Servo library .attach() but it couldn't hurt to try it.