communication without XCTU

i’m new with Arduino and Xbee.

i was able to send a frame from an End device to a Coordinator but using the X-CTU. Now need to do the same thing but without using the graphical interface (X-CTU) using only the micro-controler and writing two codes a sender.c and a receiver.c

the code needs to blink the LED depending on the field data if the field contain 3 the LED needs to blink 3 times.

 #include <XBee.h>
    This example is for Series 2 XBee
    Receives a ZB RX packet and sets a PWM value based on packet data.
    Error led is flashed if an unexpected packet is received
    XBee xbee = XBee();
    XBeeResponse response = XBeeResponse();
    // create reusable response objects for responses we expect to handle
    ZBRxResponse rx = ZBRxResponse();
    ModemStatusResponse msr = ModemStatusResponse();
    int statusLed = 13;
    int errorLed = 13;
    int dataLed = 13;
    void flashLed(int pin, int times, int wait) {
        for (int i = 0; i < times; i++) {
          digitalWrite(pin, HIGH);
          digitalWrite(pin, LOW);
          if (i + 1 < times) {
    void setup() {
      pinMode(statusLed, OUTPUT);
      pinMode(errorLed, OUTPUT);
      pinMode(dataLed,  OUTPUT);
      // start serial
      flashLed(statusLed, 3, 50);
    // continuously reads packets, looking for ZB Receive or Modem Status
    void loop() {
        if (xbee.getResponse().isAvailable()) {
          // got something
          if (xbee.getResponse().getApiId() == ZB_RX_RESPONSE) {
            // got a zb rx packet
            // now fill our zb rx class
            if (rx.getOption() == ZB_PACKET_ACKNOWLEDGED) {
                // the sender got an ACK
                flashLed(statusLed, 10, 10);
            } else {
                // we got it (obviously) but sender didn't get an ACK
                flashLed(errorLed, 2, 20);
            // set dataLed PWM to value of the first byte in the data
            analogWrite(dataLed, rx.getData(0));
          } else if (xbee.getResponse().getApiId() == MODEM_STATUS_RESPONSE) {
            // the local XBee sends this response on certain events, like association/dissociation
            if (msr.getStatus() == ASSOCIATED) {
              // yay this is great.  flash led
              flashLed(statusLed, 10, 10);
            } else if (msr.getStatus() == DISASSOCIATED) {
              // this is awful.. flash led to show our discontent
              flashLed(errorLed, 10, 10);
            } else {
              // another status
              flashLed(statusLed, 5, 10);
          } else {
            // not something we were expecting
            flashLed(errorLed, 1, 25);    
        } else if (xbee.getResponse().isError()) {
          //nss.print("Error reading packet.  Error code: ");  

If you are only sending the text "3", why are you using API mode? AT mode is so much simpler.

What is that code actually doing? Which Arduino (sender or receiver) is it on? What is on the other one?

hello sir thank you for your answer it's a receiver code and the professor asked us not to use the AT mode !

the professor asked us not to use the AT mode !

Not using AT mode in the final project might be reasonable.

Not using it to at least confirm that the configuration and hardware are correct is not.