Divide Code on transmisor/receptor

Hi guys!
Please i need to divide this into transmisor (mega 2560,mpu 6050 and hc05)
to receptor(Arduino micro and hc05)

I tried but i miss something...
Thanks to KingDubDub for the Code!!!

/* Tilt Control (Mouse Version) - King Dub Dub, 12/1/19

A tilt-controller script for USB-HID enabled Arduino boards with the MPU-6050 sensor.
Tilt to control an emulated mouse input, up for up, right for right, and so on.
There is an additional fail-safe that keeps any mouse data from being printed if pin 9
isn't grounded. Ground pin 9 with a switch/button when you want to send keyboard inputs.

MPU6050 - Arduino
VCC to 5V
GND to GND
SCL to A5 or SCL
SDA to A4 or SDA
ADO to GND
INT to digital pin 2
Pin 9 to button/switch to ground

*/

#include<Wire.h>
#include<Mouse.h>

const int MPU_addr=0x68;
int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ; //sets up the accelerometer XYZ's, temperature, and gyro XYZ's
int minVal=265; //math-error
int maxVal=402; //checking
double x,y,z;
int MPUFail = 0;

void setup(){
  Wire.begin();
  Wire.beginTransmission(MPU_addr);
  Wire.write(0x6B);
  Wire.write(0);
  Wire.endTransmission(true);
  Serial.begin(9600);

  pinMode(9, INPUT_PULLUP); //pin 9 is a fail-safe switch
  Mouse.begin();
}

void loop(){
  Wire.beginTransmission(MPU_addr);
  Wire.write(0x3B); Wire.endTransmission(false);
  Wire.requestFrom(MPU_addr,14,true);
  AcX=Wire.read()<<8|Wire.read();
  AcY=Wire.read()<<8|Wire.read();
  AcZ=Wire.read()<<8|Wire.read();

  int xAng = map(AcX,minVal,maxVal,-90,90);
  int yAng = map(AcY,minVal,maxVal,-90,90);
  int zAng = map(AcZ,minVal,maxVal,-90,90);

  x= RAD_TO_DEG * (atan2(-yAng, -zAng)+PI);
  y= RAD_TO_DEG * (atan2(-xAng, -zAng)+PI);
  z= RAD_TO_DEG * (atan2(-yAng, -xAng)+PI);
  
  if ((AcX == -1) and (AcY == -1) and (AcZ == -1)){
    MPUFail = 1; //if the Arduino can't connect to the MPU, all raw values come out as -1,
  } else {       // so this is another fail-safe that stops it from pressing keys.            
    MPUFail = 0;
  }

  Serial.print("X= "); Serial.print("N/A"); //the X value doesn't work on our axis
  Serial.print(" Y= "); Serial.print(y);    //print the Y value
  Serial.print(" Z= "); Serial.print(z);    //print the Z value
  Serial.print("  Safety: ");
  if(digitalRead(9) == 0){ //prints if safety button is on:
    Serial.print("Off");
  } else {
    Serial.print("On");
  }
  Serial.print("\n"); //prints a new line

  if ((y >=130) and (digitalRead(9) == 0) and (MPUFail == 0)){ //if tilted left:
    Mouse.move(-10, 0, 0); //move mouse left 10 units
    delay(10);
  }
  if ((z <=340) and (z >= 180) and (digitalRead(9) == 0) and (MPUFail == 0)){ //if tilted down:
    Mouse.move(0, -10, 0); //move mouse down 10 units
    delay(10);
  }
  if ((y<=60) and (digitalRead(9) == 0) and (MPUFail == 0)){ //if tilted right:
    Mouse.move(10, 0, 0); //move mouse right 10 units
    delay(10);
  }
  if ((z >= 35) and (z<=179) and (digitalRead(9) == 0) and (MPUFail == 0)){ //if tilted up:
    Mouse.move(0, 10, 0); //move mouse up 10 units
    delay(10);
  }
  delay(10);//keeps a regulated speed
}

Post your best effort.

What u mean??

What he/she means is that you must show what you tried.

I tried but i miss something

This is not an Installation and Troubleshooting question.

Sorry sir i deleted the try... Can you help me please?

TonyMaz:
Sorry sir i deleted the try... Can you help me please?

If you mean that you have lost the program that you have been trying then the best thing to do is write it again and if it does not work post the program and tell us in detail what it actually does and what you want it to do that is different. It will make it much easier to focus on the parts you need help with rather than wasting time on things that you can do.

Or, if you just want someone to write a program for you please ask in the Gigs and Collaborations section of the Forum and be prepared to pay.

...R