How to clear serial buffer garbage after toggling remote Xbee s2/s2cdigital pin?

Hey. I have written a program to toggle digital pin of Remote Xbee. the code:

void setup(){
  pinMode(led, OUTPUT);
  Serial.begin(9600);
  
}

void loop(){
  
setRemoteState1(0x5);
delay(1000);
setRemoteState1(0x4);
  delay(1000);
   

}



// first xbee
void setRemoteState1 (char value){
  
 Serial.write(0x7E); //start byte
 Serial.write((byte)0x0); //high part of length (always zero)
 Serial.write(0x10);  //low part of length
 Serial.write(0x17); //0x17 is remote AT command
 Serial.write((byte)0x0);  //frame ID set to zero for no reply
 Serial.write(0x00);
 Serial.write(0x13);
 Serial.write(0xA2);
 Serial.write(0x00);
 Serial.write(0x41);
 Serial.write(0x82);
 Serial.write(0xD1);
 Serial.write(0xB9);
  
  //16 bit of recipient of 0xFFFE
  Serial.write(0x2D);
  Serial.write(0xCD);
  Serial.write(0x02);
  Serial.write('D');
  Serial.write('4');

  //command data in as many bytes
  Serial.write(value);
  
  //checksum
  long sum = 0x17 + 0x13 + 0xA2 + 0x41 + 0x82 +0xD1+0xB9+0x2D+0xCD + 0x02 + 'D' + '4' + value;
  Serial.write(0xFF - (sum & 0xFF));
   
}

At the serial monitor, every time the digital pin is triggered, I am receiving some garbage data. I want to use another remote Xbee to send the message back to the coordinator but I cannot do that because of that garbage data.

https://imgur.com/a/2HMXgbz

Your image is unreadable. Please don't post pictures of text, just copy and paste the text.

...R

I did not put any pictures of text, I have used code tags to ident the code. I can read my image perfectly, not sure whats wrong with yours.

I don't see any picture in your Original Post or in your Reply #2.

There is a link to an image in your Original Post.

...R