servo motor control with joystick through blue tooth

pl find attached here with the two programs (master & slave) done on two arduino boards with two HC05 blue tooth module as master and slave.
with these programs when i change the joystick no moment

t in motor and also no display of joystick data on receiver serial monitor.
If I send some integer value from Master serial monitor and press send the same value is displaying on slave serial monitor. And motor is moving one step. If next time sends the value no moment in motor.
Mastercode:

#include <SoftwareSerial.h>


SoftwareSerial BTSerial(10, 11); 
int potValue =0;
void setup()
{


Serial.begin(38400);
Serial.println("Arduino is ready");


BTSerial.begin(38400); 
}
void loop() {
  potValue=analogRead(A0);
  int potValueMapped=map(potValue,0,1023,0,255);
  Serial.write(potValueMapped);
  
  if(Serial.available())
  BTSerial.write(Serial.read());


  if(BTSerial.available())
  Serial.write(BTSerial.read());


}

Slave Code:

#include <SoftwareSerial.h>
#include<Servo.h>


SoftwareSerial BTSerial(10, 11); // RX | TX


Servo myServo;
int input = 20;


void setup() {
  myServo.attach(9);
  Serial.begin(38400);


  Serial.println("Enter your commands:");
  BTSerial.begin(38400);
}




void loop() {


  if (BTSerial.available())  //RECEIVE
    {Serial.write(BTSerial.read());
    
    input = Serial.read();}
    myServo.write(input);
  


  if (Serial.available())
  { BTSerial.write(Serial.read());
  }
 
}

There are a few problems.

In the master program this is sending an int variable and an int is made up of two bytes

Serial.write(potValueMapped);

And in the slave program the two read() calls in this

    {Serial.write(BTSerial.read());
    
    input = Serial.read();}

read the two bytes of int separately - the first part is sent back to the master and the second part is used for the servo.

Another problem is that master is sending the data too often - it is sending it as fast as loop() can repeat. Sending data about 5 times per second should be sufficient to get a good response.

Rather than trying to fix all that, it is much easier to debug a program if you send data as text using Serial.print()

Have a look at the examples in Serial Input Basics - simple reliable non-blocking ways to receive data. There is also a parse example to illustrate how to extract numbers from the received text.

The technique in the 3rd example will be the most reliable. It is what I use for Arduino to Arduino and Arduino to PC communication.

You can send data in a compatible format with code like this (or the equivalent in any other programming language)

Serial.print('<'); // start marker
Serial.print(value1);
Serial.print(','); // comma separator
Serial.print(value2);
Serial.println('>'); // end marker

...R

can you please make corrections in my code.

odces:
can you please make corrections in my code.

Have you tried the code in my Tutorial?

...R

I have not clearly understand the examples please.

odces:
I have not clearly understand the examples please.

I 'm sure you did understand the titel. And the first words in the first sentence. Pretty sure even more. But of course there is a point you don't understand. So please ask a concrete question right there where the first question arises.
Concrete questions will help a lot to get you going
best regards Stefan

odces:
I have not clearly understand the examples please.

If you tell us the part you don't understand I will try to help.

...R