Xbees don't connect. RSSI Doesn't blink

I am working on a RC Gripper lifter that works with 2 Servos and 2 DC motors. For wireless control I am using a Series 1 configured Xbee. Now the problem is that the Xbees don’t connect when I upload the code. They do connect if I upload some other small code. Here’s the Sender Code

  int potGripper = 1;
  int potLifter = 2;
  //int oldGripper = 0;
  int newGripper = 0;
  //int oldLifter = 0;
  int newLifter = 0;
  int midPin = 2;
  int leftPin = 3;
  int newGear =0;
  int oldGear=1;
void setup() 
{
  Serial.begin(9600);
 pinMode(midPin, INPUT);
 pinMode(leftPin, INPUT);
 pinMode(potGripper, INPUT);
 pinMode(potLifter, INPUT);

}

void loop() {
  if ( digitalRead(midPin) == LOW)
  {
     oldGear = 1;
  }
  else if ( digitalRead(leftPin) == LOW)
  {
      oldGear = 2;
  }
  
  int oldGripper = analogRead(potGripper);
  int oldLifter = analogRead(potLifter);
  int Grippervalue = map(oldGripper,0,1023,0,9);
  int Liftervalue = map(oldLifter,0,1023,0,9);
  if(newGripper != Grippervalue)
  {
    Serial.println('!');
    Serial.println(Grippervalue);
    Serial.println('#');
    newGripper = Grippervalue;
  }
  else if(newLifter != Liftervalue)
  {
    Serial.println('@');
    Serial.println(Liftervalue);
    Serial.println('#');
    newLifter = Liftervalue;
  }
  else if( newGear != oldGear)
  {
    Serial.println(';');
    Serial.println(oldGear);
    Serial.println('#');
    newGear = oldGear;
  }
  delay(500);
}

and here’s the reciever code-

#include <Servo.h>
//If serial dsn't work as expected, add  while(Serial.available()>0) Serial.read(); at end of each loop!
int gripperPin = 9;
int lifterPin = 10;
int rpmData = 0;
int motorLeft, motorRight, gripperData, lifterData, angle, flag;

Servo myGripper;
Servo myLifter;

void setup() {
  Serial.begin(9600);
  myGripper.attach(gripperPin);
  myLifter.attach(lifterPin);
  delay(500);
}

void loop() {
  while( Serial.available() == 0);
  int data = Serial.read() - '0';
if (data >=0)
  {
    if(data == ';') // For setting the motor RPM
    {
      rpmData= Serial.read() - '0';
      if (rpmData == 0)
      {
       motorLeft= 300;
       motorRight= 250;
      }
      else if (rpmData == 1)
      {
        motorLeft= 200;
        motorRight= 150;
      }
    }
    if (data == '!') // For the Gripper
    {
      gripperData = Serial.read() - '0';
      angle= map(gripperData, 0, 9, 0, 80);
      myGripper.write(angle);
     }
    if (data == '@') // For the Lifter
    {
      lifterData = Serial.read() - '0';
      angle= map(lifterData, 0, 9, 0, 160);
      myLifter.write(angle);
    }
    //if (data == '%') // For the Buttons
     if (data == '#') // For marking end of Serial Data
     {
      flag = 0;
     }
     }
    }

My main aim is to send a value between 0-9 from one arduino to another so that I can map it on the other arduino from 0-160 and 0-80 (I am using 2 servos). I have used a symbol to differentiate the values from each other so that the correct value reaches the desired servo/motor. Please help me figure out my mistake…

For wireless control I am using a Series 1 configured Xbee.

One of them? That’s like having one shoe.

Now the problem is that the Xbees don’t connect when I upload the code. They do connect if I upload some other small code. Here’s the Sender Code

Unless the code is diddling with the configuration of the XBee, the ability of the XBee(s) to connect is NOT dependent on the code.

The ability to communicate might be.

Please help me figure out my mistake…

That’s going to be hard since we don’t know how many XBees you have, how it (or they) are configured, how it (or they) are connected to the Arduinos, or what the code you posted actually does.