0
votes

I am trying to attach a servo on an Arduino (branded) Robot but not sure whhich pin to use for the bellow code. Most people seem to recommend to use pin 9 and 10 to control the servo for arduino Unos. However, I can't use Pin 9 because that is already used as the Slave Select pin for the LCD. I have tried attaching it to pins TKD0-TKD3 by calling them pins 19-22 in myservo.attach(). The code runs but the servo doesn't rotate and only gets hot and/or twitches.

Could the problem be something other than incorrect pin connection?

Thanks, -M

I have been referencing these for the Control board pin mapping: http://arduino.cc/en/Main/Robot) http://fabcirablog.weebly.com/blog/grappling-with-the-arduino-robot-control-board

#include <Servo.h> 

Servo myservo;  // create servo object to control a servo 


int pos = 0;    

void setup() 
{ 

  myservo.attach(19);  // 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);                       
  } 
}
1
Do you have a regular Arduino Uno that you can try with the servo? This would just be so you could verify there isn't something wrong with the servo. Your code is fine. Do you have the servo wired correctly to the robot? Is your plug reversed? These are just some ideas of things to check. - Tim Cavanaugh
Thanks Tim, I don't have an Arduino Uno handy but I used another servo to verify. Yes I believe the wiring is correct and I tried various combinations to make sure - mimas

1 Answers

0
votes

You have this robot, right?

Arduino Robot

And you are using a classic servo (3 pins, yellow red and black cable)? If so.... Watch out. According to the schematic, the pinout of the connector on the board (e.g. TKD0) is

+5V
AD1
GND

While usually servos have

DATA
+5V
GND

So.. you have to make a short cable to invert the pins.

If that's not the problem.. Are you sure that 19 is the right number for the pin? I can't find references, but i suggest you to call it TKD0 (which is probably a macro defining the right pin), as arduino designers suggest you.