I/O control over serial

You are sending pin stauts which is either '1 (ASCII0x31)' or '0 (ASCII 0x30)'. Why are you sending '2 (ASCII 0x32)' instead of '0'?

You have said that you are communicating between two Arduinos; then where is the sketch of UNO-2? I see the UNO-2's codes are with UNO-1. Are you testing through loop back connection. If you are using two UNOs, then connect them using software Serial Port (SUART) as the hardware UART Port remains engaged with Serial Monitor/IDE.

Moreover, your codes of ReceiveData() functiion could also be written as follows:

void ReceiveData() 
{
  byte n = Serial.available();
  if(n != 0)
  {
    if(flag == false)
    {
      char x = Serial.read();
      if(x == 'S')
      {
        flag = true;
      }
    }
    else
    {
      byte m = Serial.readBytesUntil('E', ReceivedData, 20);
      ReceivedData[m] = '\0'; //null-byte
      Serial.println(ReceivedData);
      //----- process data of the array-----------
      flag = false;
    }
  }