Communication between Arduino through Xbee not working..pls help me

Hi friends,I am trying to design a mesh network using Xbee s2 and arduinos.In the first stage I am trying to create communication between two arduinos using Xbee s2,I am using the AT mode.I have programmed the arduino as follows

Sender:

void setup() {
Serial.begin(9600);
}
void loop() {
 Serial.println("1"); //turn on the LED
delay(1000);
Serial.println("0");//turn off the LED
delay(1000);

  
}

Receiver:

int ledPin = 13;  // use the built in LED on pin 13 of the Uno
int state = 0;
int flag = 0;        // make sure that you return the state only once

void setup() {
    // sets the pins as outputs:
    pinMode(ledPin, OUTPUT);
    digitalWrite(ledPin, LOW);

    Serial.begin(9600); // Default connection rate for my BT module
}

void loop() {
    //if some data is sent, read it and save it in the state variable
    if(Serial.available() > 0){
           state = Serial.read();
      flag=0;
    }
    // if the state is 0 the led will turn off
    if (state == '0') {
        digitalWrite(ledPin, LOW);
        if(flag == 0){
          Serial.println("LED: off");
          flag = 1;
        }
    }
    // if the state is 1 the led will turn on
    else if (state == '1') {
        digitalWrite(ledPin, HIGH);
        if(flag == 0){
          Serial.println("LED: on");
          flag = 1;
        }
    }
}

I am using Arduino UNO and MEGA,And configured Xbees using XCTU.I am connecting Xbees directly to the Arduions(without any shield,I have two boards with MAX232 to configure the Xbees and also I am powering Xbee through this board because there is some inbuilt 3.3V regulator) and connected TX of Xbee directly to Arduino RX and Arduino TX connected to Xbee RX through a voltage divider.

In the STEP-1 I connected arduinos using wires UNO TX to MEGA RX and UNO Rx to MEGA Tx and its
working fine.

In the STEP-2 I replaced the wired connection with Xbees but its not working

Then in STEP-3 I replaced the sender Arduino with my laptop( I used XCTU) and its working perfect without any problem.When I type 1 in terminal box the LED turned ON on and a 0 turned OFF the LED

I am attaching the YouTube video link of the 3 steps(something that I captured with my camera)

STEP-1
STEP-2
STEP-3

Please help me solve this problem,I am working on this for the past couple of days,watched a lot of tutorial videos,read a lot and tried different methods but I couldn't solve this...

And configured Xbees using XCTU.

But, it's not important how. Umm, yes, it IS.

I have two boards with MAX232 to configure the Xbees

MAX323 is for converting TTL levels to RS232 levels and back. They are not for 3.3V to 5V level shifting.

PaulS,Thanks for your reply.

MAX323 is for converting TTL levels to RS232 levels and back. They are not for 3.3V to 5V level shifting.

Yes,I know and its something like an Xbee adapter board and there is a socket to insert the Xbee and also we can power Xbee with this board using a DC adapter.And there is some jumpers available for Din,Dout and Ground