Pan and Tilt System connected to Arduino Uno ATmega328

Hello,

Can anyone point me to the right direction on what supplies I need and what code I should use (servo library) to get this ( http://www.superdroidrobots.com/shop/item.aspx?itemid=825 ) working with Arduino (wiring, where to, etc.).

I was going to use the AX-12+ Dynamixel which I have 5 of them, but I wouldn't know where to start with that. I looked at this site ( Arduino y Dynamixel AX-12 ) for a start. Didn't get it at the end.

Would I need an I/O expansion board to make things easier when connecting?

-Product

Some simple code to control two regular servos.

// zoomkat 11-22-10 serial servo (2) test
// for writeMicroseconds, use a value like 1500
// for IDE 0019 and later
// Powering a servo from the arduino usually DOES NOT WORK.
// two servo setup with two servo commands
// send eight character string like 15001500 or 14501550

#include <Servo.h> 
String readString, servo1, servo2;
Servo myservo1;  // create servo object to control a servo 
Servo myservo2;

void setup() {
  Serial.begin(9600);
  myservo1.attach(6);  //the pin for the servo control 
  myservo2.attach(7);
  Serial.println("servo-test-21"); // so I can keep track of what is loaded
}

void loop() {

  while (Serial.available()) {
    delay(1);  
    if (Serial.available() >0) {
      char c = Serial.read();  //gets one byte from serial buffer
      readString += c; //makes the string readString
    } 
  }

  if (readString.length() >0) {
      Serial.println(readString); //see what was received
      
      // expect a string like 07002100 containing the two servo positions      
      servo1 = readString.substring(0, 4); //get the first four characters
      servo2 = readString.substring(4, 8); //get the next four characters 
      
      Serial.println(servo1);  //print to serial monitor to see results
      Serial.println(servo2);
      
      int n1; //declare as number  
      int n2;
      
      char carray1[6]; //magic needed to convert string to a number 
      servo1.toCharArray(carray1, sizeof(carray1));
      n1 = atoi(carray1); 
      
      char carray2[6];
      servo2.toCharArray(carray2, sizeof(carray2));
      n2 = atoi(carray2); 
      
      myservo1.writeMicroseconds(n1); //set servo position 
      myservo2.writeMicroseconds(n2);
    readString="";
  } 
}

That first pan/tilt just uses some small hitec servos, fairly low torque. They can run on 4.8 to 6.0 volts. I wasn't able to find any current draw details on those servos, so I'd recommend running them off a separate 5-6 volt power supply.

The AX-12s are controlled via a serial protocol. They can be controlled from the Arduino, but it isn't a trivial project to get running. For one, the AX-12s are half-duplex devices. Two, most of the Arduinos only have a single serial port. Software Serial may be useable, but that would just add another layer of complication, and the Dynamixel servos are set up by default to run at high baud rates. The hitec servos would be far easier to control, as zoomkat demonstrates above.

Hello,

Thanks for the help guys. I'll let you know if it works out after I get back from work.

If there is anything to add for future readers please feel free.

-Product