Help with mpu-6050 based stabilizer

Please help me to make the servos go to the opposite direction to the tilt direction of the gyro
I used-arduino nano
Mpu 6050 gyro
2 9g servos
here is my code

#include <Wire.h>
#include <Servo.h>
 
const int MPU=0x68;  // I2C address of the MPU-6050
 
int16_t GyX, GyY; //Variabile int a 16bit
 
Servo ServoMot_X;
Servo ServoMot_Y;
 
void setup(){
  Wire.begin();
  Wire.beginTransmission(MPU);
  Wire.write(0x6B);  // PWR_MGMT_1 register
  Wire.write(0);     // set to zero (wakes up the MPU-6050)
  Wire.endTransmission(true);
  
  ServoMot_X.attach(8);
  ServoMot_Y.attach(9);
  Serial.begin(9600);
}
void loop(){
  Wire.beginTransmission(MPU);
  Wire.write(0x3B);                // starting with register 0x3B (ACCEL_XOUT_H)
  Wire.endTransmission(false);
  Wire.requestFrom(MPU,14,true);  // request a total of 14 registers
  
  GyX=Wire.read()<<8|Wire.read();  // 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L)
  GyY=Wire.read()<<8|Wire.read();  // 0x45 (GYRO_YOUT_H) & 0x46 (GYRO_YOUT_L)
 
  int PosServo_X = map(GyX, -16000, 16000, 0, 179);
  int PosServo_Y = map(GyY, -16000, 16000, 0, 179);
  ServoMot_X.write(PosServo_X);
  ServoMot_Y.write(PosServo_Y);
 
  Serial.println("Giroscopio");
  Serial.print("Asse X : "); Serial.println(PosServo_X);
  Serial.print("Asse Y : "); Serial.println(PosServo_Y);
  Serial.println(" ");
  delay(100);
}

How have you wired things up and what happens when you try to run the code?

jremington:
How have you wired things up and what happens when you try to run the code?

IT WORKS FINE WHEN I TILT GYRO LEFT SERVO TURNS RIGHT WHEN I TILT GYRO RIGHT SERVO TUNS RIGHT
I NEED TO MAKE THIS EXACTLY OPPOSITE.I HAVE USE X AND Y AXIS PLEASE HELP ME TO MAKE IT RUNNING OPPOSITE

*******GYRO CONNECTION *****

VCC - 3.3V
GNS -GND
SCL -A5
SDA -A4

************ ARDUINO AND SERVO *****

USED PWM PINS 9 AND 8

PLEASE HELP ME TO MAKE IT RUNNING OPPOSITE

Simple arithmetic usually fixes that one.

(please take off your CAPS LOCK - it looks like you're SHOUTING at us)

AWOL:
Simple arithmetic usually fixes that one.

(please take off your CAPS LOCK - it looks like you're SHOUTING at us)

i m really sorry about that i thought typing it in capital would be just fine and neat really sorry about that please show me a way or a code to make this go opposite

180 - 0 = 180
180 - 180 = 0

AWOL:
180 - 0 = 180
180 - 180 = 0

so i must change this

int PosServo_X = map(GyX, -16000, 16000, 0, 179);
  int PosServo_Y = map(GyY, -16000, 16000, 0, 179);

so i must be like this

int PosServo_X = map(GyX, -16000, 16000, 0, 180-0=180);
  int PosServo_Y = map(GyY, -16000, 16000, 0, 180-180=0);

?

Does that even compile?

AWOL:
?

Does that even compile?

naaaah just show me where i can edit the code please that would be really help full.

I don't need to show you where - you've already got the right place, just the wrong method.

Does this help?

AWOL:
I don't need to show you where - you've already got the right place, just the wrong method.

Does this help?

hmmmm that helped a lot but still please can you type me the correct code line sir please.im not forcing you if you have time

Of course I could do that - but what would you learn?
All you have to do is to change the positions of two numbers.

AWOL:
Of course I could do that - but what would you learn?
All you have to do is to change the positions of two numbers.

yeahhhhh thanks a lot sir .i will try doing that and thanks again for the help