RF Link, Multiple Variables

I’m trying to send 2 variables, from a joystick, through an FS1000A transmitter, to be received by a Mx-RM-5V receiver. I’m fairly certain im sending the correct info through the transmitter, but i am not sure how to differentiate the 2 variables when they are received. The receiver only reads one of the variables and will print only one. I am very bad at coding. Most of this isn’t my code. Please help.

Transmitter code:

const int X_pin = A0; 
const int Y_pin = A1;
int senseY;
int senseX;
#include <VirtualWire.h>
char charY{10};
char charX{10};

int Yout;
int Xout;

void setup()
{
    Serial.begin(9600);    // Debugging only
    Serial.println("setup");
    
vw_set_ptt_pin(9);
vw_set_rx_pin(A4);
vw_set_tx_pin(2);
    // Initialise the IO and ISR
    vw_set_ptt_inverted(true); // Required for DR3100
    vw_setup(2000);  // Bits per sec
}

void loop()
{
  int senseX = analogRead(X_pin);       //Sets senseX, senseY and button equal to the voltage reading of X_pin, Y_pin and SW_pin repectively
int senseY = analogRead(Y_pin);

  
 itoa(senseY, charY,10);
Yout = atoi(charY);
  itoa(senseX, charX,10);
  Xout = atoi(charX);
    Serial.print("X =");
    Serial.print(Xout);
    Serial.print("   ");
  Serial.print("Y =");
 Serial.println(Yout);
 
    vw_send((uint8_t *)charY, sizeof(charY));
   vw_wait_tx();// Wait until the whole message is gone
   delay(10);
   vw_send((uint8_t *)charX, sizeof(charX));
   vw_wait_tx(); // Wait until the whole message is gone
    delay(200);
}

Receiver code

#include <VirtualWire.h>
char Xread[10];
char Yread[10];
int Xout;
int Yout;
void setup()
{
    Serial.begin(9600);  // Debugging only
    Serial.println("setup");
vw_set_ptt_pin(9);
vw_set_rx_pin(A0);
vw_set_tx_pin(7);
    // Initialise the IO and ISR
    vw_set_ptt_inverted(true); // Required for DR3100
    vw_setup(2000);  // Bits per sec

    vw_rx_start();       // Start the receiver PLL running
}

void loop()
{
    uint8_t buf[VW_MAX_MESSAGE_LEN];
    uint8_t buflen = VW_MAX_MESSAGE_LEN;

    if (vw_get_message(buf, &buflen)) // Non-blocking
    {
  int i;

        digitalWrite(13, true); // Flash a light to show received good message
  // Message with a good checksum received, dump it.
  Serial.print("Got: ");

  
  for (i = 0; i < buflen; i++)
  {
    Yread[i] = char(buf[i]);
  }
   delay(10);
   
   int j;
  for (j = 0; j < buflen; j++)
  {
    Xread[j] = char(buf[j]);
  }



Xread[buflen] = '\0';
  Xout = atoi(Xread);
 Serial.print("X = ");
  Serial.print(Xout);

  Yread[buflen] = '\0'; 
  Yout = atoi(Yread);
  Serial.print("     Y = ");
  Serial.println(Yout);
      
    }
}

I have no idea what im doing, i just want to build a robot. if you have any questions or need anymore info, i’ll do my best.

Thanks!

I'm trying to send 2 variables, from a joystick, through an FS1000A transmitter

You KNOW that you can't send variables, right? You can send the values in variables...

char charY{10};
char charX{10};

WTF? Are those supposed to be arrays?

They are not. So, passing the addresses to itoa() is completely wrong.

Passing charX to atoi() is wrong, too.

If you DID have an array, and used sprintf() to populate it, you COULD send something like "123,456" in ONE message, which would be trivially easy to parse on the receiver.

Put the two integers in an int array with two elements or a struct with two ints. Send them both at the same time, in binary. Receive them (in binary) into the same type of array or struct. They will then be automatically "separated" for you.