Bluetooth sending values from two joysticks
Arduino A

You can read the values from two joysticks as normal and send it like this. This method ensures of no data loss. Ensure that you read the values and store them in appropriate variables and then send it over serial.

// Setting Sensor pins
const int potPin = A0;
const int pot1Pin = A1;




// Creating variables
uint8_t pot;
uint8_t pot1;

void setup() {
// Declearing the pinModes' for sensors
  pinMode(potPin, INPUT);
  pinMode(pot1Pin, INPUT);
// Begining Serial Communication
  Serial.begin(9600);

}

void loop() {
// reading from the sensors
  pot = map(analogRead(potPin),0 ,1023, 0, 255);
  pot1 = map(analogRead(pot1Pin),0 ,1023, 0, 255);  

//Packing the Serial message
  Serial.print("U*"); //A header
  Serial.print("A");  //a token to indicate the message payload
  Serial.print(pot);
  Serial.println("");  

  Serial.print("U*"); //A header
  Serial.print("B");  //a token to indicate the message payload
  Serial.print(pot1);
  Serial.println("");  


}


Arduino B

After the data are packed and sent over the serial. You need to unpack it with the other Arduino/device 

The code will look like this:

String data; //Store each line of Serial communication
String pot1String = "0", pot2String = "0";
float pot1, pot2;
void setup() 
{
  //initialize Serial communication 
  Serial.begin(9600);
  //read first package
  if (Serial.available() &gt; 0)
  {
    data = Serial.readStringUntil('\n');
  }
  //Disregard the first reading
  data = "0";
}

void loop() {
  //start reading from serial
  if (Serial.available() &gt; 0)
  {
    data = Serial.readStringUntil('\n');  
  }
  String payload = ""; 
  if (data != "0")
  {
    int offset = data.indexOf("U*"); //This is the header (0x552A)
    if (offset &gt;= 0)
    {
      payload = data.substring(offset + 3, data.indexOf('\n'));
      char value = data.charAt (offset + 2);
      switch (value)
      {
        case 'A':
          pot1String = payload;
          break;
        case 'B':
          pot2String = payload;
          break;
      //Add more case as the project grow
      }
    }
  }
  //convert strings to float
  pot1 = pot1String.toFloat();
  pot2 = pot2String.toFloat();

// Continue with the rest of your project

}



Make sure to use the same baud rate in both sketches


Hope this helped. Ask me if you have farther questions