Joystick + 2 servos

Hi guys,

was playing with servos, I used this code:

#include <Servo.h>

const int servo1 = 6;       // first servo
const int servo2 = 7;       // second servo
const int joyH = A0;        // L/R Parallax Thumbstick
const int joyV = A1;        // U/D Parallax Thumbstick

int servoVal1;           // variable to read the value from the analog pin
int servoVal2;
Servo myservo1;  // create servo object to control a servo
Servo myservo2;  // create servo object to control a servo



void setup() {

  // Servo  
  myservo1.attach(servo1);  // attaches the servo
  myservo2.attach(servo2);  // attaches the servo

  // Inizialize Serial
  Serial.begin(9600);
}


void loop(){

    // Display Joystick values using the serial monitor
    outputJoystick();

    // Read the horizontal joystick value  (value between 0 and 1023)
    servoVal1 = analogRead(joyH);          
    servoVal1 = map(servoVal1, 0, 1023, 90, 180);     // scale it to use it with the servo (result  between 0 and 180)

    myservo1.write(servoVal1);                         // sets the servo position according to the scaled value    

    // Read the horizontal joystick value  (value between 0 and 1023)
    servoVal2 = analogRead(joyV);           
    servoVal2 = map(servoVal2, 0, 1023, 0, 90);     // scale it to use it with the servo (result between 70 and 180)

    myservo2.write(servoVal2);                           // sets the servo position according to the scaled value

    delay(15);                                       // waits for the servo to get there

}

I want to get next - when I move joy to the right, 1st servo goes from 90 to 180 degrees, and when I move joy to the left, 2nd servo goes to other side, from 90 to 0 degree.
I tried to change servoval2 to read same as servoval1, and changed map for both of them, but then they move at the same time at same directions.

I would be very grateful for some help…

I tried to change servoval2 to read same as servoval1, and changed map for both of them, but then they move at the same time at same directions.

If one moves from 0 to 180, the other needs to move from 180 to 0, right? If the position of one is (to be) pos, the position of the other one is (to be) 180-pos.

but then they move at the same time at same directions.

Below is basic servo test code used with continuous rotation servos that are used to drive bot wheels. The code has the servos move in same directions at approximately the same speed.

//zoomkat 10-09-14 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="";
  } 
}