SEND RECEIVE MULTIPLE DATA

I don´t have test the codes.

bellow the sending code

#define buttonPin 8

int pA1 = A0;
int pA2 = A1;
int pA3 = A2;
int pA4 = A3;
int pA5 = A4;

int bm = 0;

int buttonPinState = 0;
int i = 0;

const unsigned int n = 2;

unsigned int flep1[n];
unsigned int flep2[n];
unsigned int flep3[n];
unsigned int flep4[n];
unsigned int flep5[n];

unsigned int angle1[n];
unsigned int angle2[n];
unsigned int angle3[n];
unsigned int angle4[n];
unsigned int angle5[n];

void setup() 
{
  
  pinMode(buttonPin, INPUT);
  Serial.begin(9600);
  
}

void loop() 
{

  while (i < n)
  {
    Serial.write('r');

    int pote = analogRead(pA1);
    int mapote = (map(pote, 0, 1024, 0, 180));
    Serial.write(mapote);

    /*

    int flex1 = analogRead(pA2);
    int mapf1 = (map(flex1, 0, 1024, 0, 180));
    Serial.write(mapf1);

    int flex2 = analogRead(pA3);
    int mapf2 = (map(flex2, 0, 1024, 0, 180));
    Serial.write(mapf2);

    int flex3 = analogRead(pA4);
    int mapf3 = (map(flex3, 0, 1024, 0, 180));
    Serial.write(mapf3);

    int flex4 = analogRead(pA5);
    int mapf4 = (map(flex4, 0, 1024, 0, 180));
    Serial.write(mapf4);
    
    */

    
    buttonPinState = digitalRead(buttonPin);
    
    if (buttonPinState == HIGH)
    {
      
      bm = 1;
      
    }
    
    if ((buttonPinState == LOW) && (bm == 1))
    {
      
      flep1[i] = analogRead(pA1);

      /*

      flep2[i] = analogRead(pA2);

      flep3[i] = analogRead(pA3);

      flep4[i] = analogRead(pA4);

      flep5[i] = analogRead(pA5);

      */

      i++;

      bm = 2;
      
    }
  }
  
  if ((i == 2) && (bm == 2))
  {
    
    for (int pr = 0; pr < n; pr++)
    {
      
      angle1[pr] = map(flep1[pr], 0, 1024, 0, 180);

      /*
      
      angle2[pr] = map(flep2[pr], 0, 1024, 0, 180);

      angle3[pr] = map(flep3[pr], 0, 1024, 0, 180);

      angle4[pr] = map(flep4[pr], 0, 1024, 0, 180);

      angle5[pr] = map(flep5[pr], 0, 1024, 0, 180);

      */

      bm = 3;
      
    }
  }
  
  buttonPinState = digitalRead(buttonPin);
  
  if ((buttonPinState == HIGH) && (bm == 3) || (buttonPinState == HIGH) && (bm == 5))
  {
    
    bm = 4;
    
  }
  
  if ((buttonPinState == LOW) && (bm == 4))
  {
    
    for (int c = 0; c < n; c++)
    {
      
      Serial.write('m');

      Serial.write(angle1[c]);

      /*

      Serial.write(angle2[c]);

      Serial.write(angle3[c]);

      Serial.write(angle4[c]);

      Serial.write(angle5[c]);

       */

      delay(500);

      bm = 5;
      
    }
  }
}

bellow the receiving code

#include <Servo.h>
Servo myservo;
Servo myservo1;
Servo myservo2;
Servo myservo3;
Servo myservo4;
Servo myservo5;

int memomode = 0;
int i = 0;
int state = 0;
const unsigned int n = 2;

unsigned int angle1[n];
unsigned int angle2[n];
unsigned int angle3[n];
unsigned int angle4[n];
unsigned int angle5[n];

void setup()
{
  myservo.attach(3);
  myservo1.attach(4);
  myservo2.attach(5);
  myservo3.attach(6);
  myservo4.attach(7);
  myservo5.attach(8);
  Serial.begin(9600);
}

void loop()
{
  if (Serial.available() > 0) { 
    state = Serial.read(); 
  }
  
  if ((state == 'r') || (memomode = 1))
  {
    memomode = 1;
    
    if (Serial.available() == 5)
    {
      myservo.write(Serial.read());
      myservo1.write(Serial.read());
      myservo2.write(Serial.read());
      myservo3.write(Serial.read());
      myservo4.write(Serial.read());
      myservo5.write(Serial.read());
      memomode = 0;

    }
  }
  if ((state == 'm') || (memomode = 2))
  {
    memomode = 2;
    if (Serial.available() == 5)
    {
      angle1[i] = Serial.read();
      angle2[i] = Serial.read();
      angle3[i] = Serial.read();
      angle4[i] = Serial.read();
      angle5[i] = Serial.read();
      i++;
      memomode = 0;

    }
  }
}