control 3 servos with 2 analog joysticks

hi

i'm new with arduino

could somebody please explain me which is the easyest way to control 3 servos with 2 joysticks

i need that 2 of the servos work at the same time, so when i move the joystick forward, both start to work, and when i move the joystick backwards, both start to run but in the other direction...
when i move the joystick left only one should run and when i move the joystick right, the other servo starts to run

the third servo should work separatly with the other joystick

please help...

Are you able to find an example of controlling one servo and can you get that to work on your Arduino? The "knob" example included with Arduino seems like a good place to start.

Are you building a tank or skid-steer robot? I would not choose to use servos to do that.

Have a look at the code in this Thread about an excavator. It may be dealing with a similar problem.

...R

Well you hook the first servo (oops....) joystick :-[ up to 2x analog pins for a start. Then the back and forth movement is exactly ala Knob as MorganS says, just having both servos using the myservo.write(val) twice, with (say) myservo1 and myservo2.

Then for the sideways, where only one is working at a time, you need an "if" to see if the incoming (raw) val is under 512. If it is, map the value to servo1 and if it's not then map it to servo2.

For the third servo, that's just plain knob, realising of course you'll only use one axis of the joystick.

Something like that anyway, that's off the top of my head.

YMMV, E&OE.

thanks a lot
i will try whith that...
and Morgan S: i'm gona use ESC to control motors, but for de arduino, an ESC is like a servo :wink:

Well you hook the first servo up to 2x analog pins for a start

Jim - you might want to review this

The below code would be used with two continuous rotation servos that are both adjusted for a 90 deg command for the neutral no movement position. The servos are usually on opposite sides of the bot, so they normally have to rotate in opposite directions.

//zoomkat 10-09-12 serial servo test
//type servo position 0 to 180 in serial monitor
//opposite side servos rotate together

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

void setup() {
  Serial.begin(9600);
  myservo1.attach(8);
  myservo2.attach(9);
  Serial.println("servo-test"); // so I can keep track of what is loaded
}

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 
    int n = readString.toInt();  //convert readString into a number
    myservo1.write(n);
    myservo2.write(180-n); //turns opposide servo in desired direction
    readString="";
  } 
}

UKHeliBob:
Jim - you might want to review this

Oh crap, thanks. Fixed....