 
 void set_channel() { 
   radio.stopListening();
-
-  my_pipe = msg_from_central[1];
-
-  radio.openReadingPipe(1,pipe[my_pipe]);
-  radio.openWritingPipe(pipe[my_pipe+1]);
-
+  
+  setPipes(msg_from_central[1]);
   radio.startListening();  
 }
 
 void loop() {
   bool has_received_message = test_receive();
-  if (my_pipe == 0) {
+  if (my_pipe == start_pipe) {
     if (has_received_message)
       set_channel();
   }

  radio.setDataRate(RF24_2MBPS);
  radio.setChannel(108);

  radio.openReadingPipe(1,pipe[my_pipe]);
  radio.openWritingPipe(pipe[my_pipe+1]);    //n0->central pelo pipe0  

  radio.startListening();
}



byte pipe[][6] = {"1Node","2Node","3Node","4Node"}; 
int send_msg[2]; //number of pipes

int start_pipe = 0;
int my_pipe;

void setPipes(int new_pipe) {
  my_pipe = new_pipe;
  radio.openReadingPipe(1,pipe[my_pipe]);
  radio.openWritingPipe(pipe[my_pipe+1]);    //n0->central pelo pipe0    
}

void setup() {
  Serial.begin(250000);
