Converting Array into Int

Issue is in my void loop. I am receiving an array with a single digit number using RF antennas. If I print the text received I get the number being sent. When I try to pull that single digit number out it is giving me random two digit numbers all beginning with 5. When I move the button (on the other Arduino sending the number over it changes the second digit but the first always stays a 5). Again, if I print the array directly it prints correctly but never when I try to cast it as an int or char to compare.

//Include Libraries
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

//Motors
int motor1pin1 = 2;
int motor1pin2 = 3;
int motor2pin1 = 4;
int motor2pin2 = 5;

int numbers;

//create an RF24 object
RF24 radio(9, 10);  // CE, CSN

//address through which two modules communicate.
const byte address[6] = "10011";

void setup()
{
  while (!Serial);
    Serial.begin(9600);
  
  radio.begin();
  
  //set the address
  radio.openReadingPipe(0, address);
  
  //Set module as receiver
  radio.startListening();
  
  //Setup for motors
  pinMode(motor1pin1, OUTPUT);
  pinMode(motor1pin2, OUTPUT);
  pinMode(motor2pin1, OUTPUT);
  pinMode(motor2pin2, OUTPUT);
}

void loop()
{
  //Read the data if available in buffer
  //
  if (radio.available())
  {
    char text[32] = {0};
    radio.read(&text, sizeof(text));
    Serial.println(text);
    //numbers = int(text);
    numbers = int(text[0]);
    Serial.print("numbers is: ");
    Serial.println(numbers);
    
    car(numbers);
  }
}


void car(int number){
  Serial.print("number = ");
  Serial.println(number);
  //move forward
  if (number == 2){
    digitalWrite(motor1pin1, HIGH);
    digitalWrite(motor1pin2, LOW);
    digitalWrite(motor2pin1, HIGH);
    digitalWrite(motor2pin2, LOW);
    Serial.println("Motor Forward");
  }
  //Staying still
  else if (number == 5){
    digitalWrite(motor1pin1, LOW);
    digitalWrite(motor1pin2, LOW);
    digitalWrite(motor2pin1, LOW);
    digitalWrite(motor2pin2, LOW);
    Serial.println("all stop");
  }
  //Forward to the left
  else if (number == 1){
    digitalWrite(motor1pin1, HIGH);
    digitalWrite(motor1pin2, LOW);
    digitalWrite(motor2pin1, HIGH);
    digitalWrite(motor2pin2, LOW);
    delay(100);
    digitalWrite(motor1pin1, LOW);
    digitalWrite(motor1pin2, LOW);
    digitalWrite(motor2pin1, HIGH);
    digitalWrite(motor2pin2, LOW);
    delay(100);
  }
  //Forward to the right
  else if (number == 3){
    digitalWrite(motor1pin1, HIGH);
    digitalWrite(motor1pin2, LOW);
    digitalWrite(motor2pin1, HIGH);
    digitalWrite(motor2pin2, LOW);
    delay(100);
    digitalWrite(motor1pin1, HIGH);
    digitalWrite(motor1pin2, LOW);
    digitalWrite(motor2pin1, LOW);
    digitalWrite(motor2pin2, LOW);
    delay(100);
  }
  //Move backwards
  else if(number == 8){
    digitalWrite(motor1pin1, LOW);
    digitalWrite(motor1pin2, HIGH);
    digitalWrite(motor2pin1, LOW);
    digitalWrite(motor2pin2, HIGH);
  }
  //Rotate/spin left
  else if (number == 4){
    digitalWrite(motor1pin1, LOW);
    digitalWrite(motor1pin2, LOW);
    digitalWrite(motor2pin1, HIGH);
    digitalWrite(motor2pin2, LOW);
  }
  //Rotate/spin right
  else if (number == 6){
    digitalWrite(motor1pin1, HIGH);
    digitalWrite(motor1pin2, LOW);
    digitalWrite(motor2pin1, LOW);
    digitalWrite(motor2pin2, LOW);
  }
  //Backwards to the left
  else if (number == 7){
    digitalWrite(motor1pin1, LOW);
    digitalWrite(motor1pin2, HIGH);
    digitalWrite(motor2pin1, LOW);
    digitalWrite(motor2pin2, HIGH);
    delay(100);
    digitalWrite(motor1pin1, LOW);
    digitalWrite(motor1pin2, LOW);
    digitalWrite(motor2pin1, LOW);
    digitalWrite(motor2pin2, HIGH);
    delay(100);
  }
  //Backwards to the RIGHT
  else if (number == 9){
    digitalWrite(motor1pin1, LOW);
    digitalWrite(motor1pin2, HIGH);
    digitalWrite(motor2pin1, LOW);
    digitalWrite(motor2pin2, HIGH);
    delay(100);
    digitalWrite(motor1pin1, LOW);
    digitalWrite(motor1pin2, HIGH);
    digitalWrite(motor2pin1, LOW);
    digitalWrite(motor2pin2, LOW);
    delay(100);
  }
}

If it a single digit number then why do you need an array ?

please post the received data as shown on your display

You are probably converting ASCII characters into numbers. Use instead something like atoi(), which translates ASCII decimal representations of numbers into binary numbers.

    numbers = atoi(text);

For more informed help, post the transmitter code.

This was your erroneous guess. You have to consult the documentation when you're in doubt.

11:34:31.082 -> 7
11:34:31.082 -> numbers is: 55
11:34:31.082 -> number = 55
11:34:31.113 -> 7
11:34:31.113 -> numbers is: 55
11:34:31.113 -> number = 55
11:34:31.113 -> 7
11:34:31.113 -> numbers is: 55
11:34:31.150 -> number = 55
11:34:31.150 -> 7

//Include Libraries
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

//Button Variables
int VRx = A0;
int VRy = A1;
int SW = 2;
int xPosition = 0;
int yPosition = 0;
int SW_state = 0;
int mapX = 0;
int mapY = 0;

//create an RF24 object
RF24 radio(9, 10);  // CE, CSN

//address through which two modules communicate.
const byte address[6] = "10011";

void setup()
{
  //button setup
  pinMode(VRx, INPUT);
  pinMode(VRy, INPUT);
  pinMode(SW, INPUT_PULLUP);
  
  radio.begin();
  
  //set the address
  radio.openWritingPipe(address);
  
  //Set module as transmitter
  radio.stopListening();
}
void loop()
{
  //Button Code
  xPosition = analogRead(VRx);
  yPosition = analogRead(VRy);
  SW_state = digitalRead(SW);

  mapX = map(xPosition, 0, 1023, -512, 512);
  mapY = map(yPosition, 0, 1023, -512, 512);

  //Send message to receiver
  //const char text[] = "Hello World";
  //radio.write(&text, sizeof(text));
  

//Forward to the right
if (mapX>50){
  if (mapY>50){
  const char text[] = "3";
  radio.write(&text, sizeof(text));
}
//rotate/spin right
  else if(mapY<50 && mapY>-50){
  const char text[] = "6";
  radio.write(&text, sizeof(text));
  }
  //backwards to the right
  else if(mapY<-50){
  const char text[] = "9";
  radio.write(&text, sizeof(text));
  }
}
//
else if (mapX>-50 && mapX<50){
  //Moving Forward
  if (mapY>50){
   const char text[] = "2";
   radio.write(&text, sizeof(text));
  }
  //Stay still
  else if (mapY>-50 && mapY<50){
   const char text[] = "5";
   radio.write(&text, sizeof(text)); 
  }
  //moving backwards
  else if (mapY<-50){
   const char text[] = "8";
   radio.write(&text, sizeof(text));  
  }
}

if (mapX<-50){
  //Back to the left
  if(mapY<-50){
   const char text[] = "7";
   radio.write(&text, sizeof(text)); 
  }
  //Move forward to the left
  else if(mapY>50){
   const char text[] = "1";
   radio.write(&text, sizeof(text)); 
  }
  //Rotate/Spin Left
  else if(mapY<50 && mapY>-50){
   const char text[] = "4";
   radio.write(&text, sizeof(text)); 
  }
}
}

atoi() will convert that, or you could use this

  int value = text[0]-'0';

You are embedding multiple declarations of a variable inside code blocks. You could do it once, for some other unknown purpose, but it may not work here. At least, it's confusing and inappropriate.

I think, you are attempting to code far above your knowledge level. Try some simpler sketches first to get the hang of it, and immediately begin to keep a C reference beside you, for guidance about how to do things.

It helps a little bit, too, to read a lot of other sketches that are known to be good, so you can see examples of how things are supposed to work.

Fundamentally, you are discovering that programming by guesswork, doesn't work.

Instead of

  if (mapY>50){
  const char text[] = "3";
  radio.write(&text, sizeof(text));
}

why not send a single byte ?

Thank you so much! I used the snippet rather than the atoi()

To everyone else thank you very much, I will pick up a few books and documentation to read up on!

When you understand the basic data types, operations and functions that use them become much clearer...

C language was originally designed for professionals. There is a lot you are supposed to "just know".