please Help - Addressing RF24 node(s)

Hello Everyone.

I need some help how to use this code below with 2 nodes or more.

The code is basically to controll 2 led using 2 button using nRF24L01.

Now I want to control LEDs on 2 nodes (2 LEDs for each Nodes) but I'm new in arduino.

my question is how to addressing the code for 2 Nodes or more? Here is the basic code :

TX :

//Programa : Teste NRF24L01 - Emissor - Botoes
//Autor : Adilson Thomsen

#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"

int data[1];

RF24 radio(9,10);

const uint64_t pipe = 0xE14BC8F482LL;

int button1 = 2;
int button2 = 3;
int button3 = 4;
int button4 = 5;
void setup()
{

  pinMode(2, INPUT);
  digitalWrite(2,HIGH);
  pinMode(3, INPUT);
  digitalWrite(3,HIGH);
  pinMode(4, INPUT);
  digitalWrite(4,HIGH);
  pinMode(5, INPUT);
  digitalWrite(5,HIGH);
  

  Serial.begin(57600);
  Serial.println(" ");
  

  radio.begin();

  radio.openWritingPipe(pipe);
}

void loop()
{

  if (digitalRead(button1) == LOW)
  {
    Serial.println(" ");
    data[0] = 1;
    radio.write(data, 1);
  }
  

  if (digitalRead(button2) == LOW)
  {
    Serial.println(" ");
    data[0] = 2;
    radio.write(data, 1);
  }

    if (digitalRead(button3) == LOW)
  {
    Serial.println(" ");
    data[0] = 3;
    radio.write(data, 1);
  }
  
    if (digitalRead(button4) == LOW)
  {
    Serial.println(" ");
    data[0] = 4;
    radio.write(data, 1);
  }
}

RX :

//Programa : Teste NRF24L01 - Emissor - Botoes
//Autor : Adilson Thomsen

#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"

int data[1];

RF24 radio(9,10);

const uint64_t pipe = 0xE14BC8F482LL;

int button1 = 2;
int button2 = 3;
int button3 = 4;
int button4 = 5;
void setup()
{

  pinMode(2, INPUT);
  digitalWrite(2,HIGH);
  pinMode(3, INPUT);
  digitalWrite(3,HIGH);
  pinMode(4, INPUT);
  digitalWrite(4,HIGH);
  pinMode(5, INPUT);
  digitalWrite(5,HIGH);
  

  Serial.begin(57600);
  Serial.println(" ");
  

  radio.begin();

  radio.openWritingPipe(pipe);
}

void loop()
{

  if (digitalRead(button1) == LOW)
  {
    Serial.println(" ");
    data[0] = 1;
    radio.write(data, 1);
  }
  

  if (digitalRead(button2) == LOW)
  {
    Serial.println(" ");
    data[0] = 2;
    radio.write(data, 1);
  }

    if (digitalRead(button3) == LOW)
  {
    Serial.println(" ");
    data[0] = 3;
    radio.write(data, 1);
  }
  
    if (digitalRead(button4) == LOW)
  {
    Serial.println(" ");
    data[0] = 4;
    radio.write(data, 1);
  }
}

Or maybe someone have another better suggestions? thank you before.

Can anybody help me please?

Bumping your Post after about 6 hours is unreasonable. After 48 hours would be OK.

Have a look at this Simple nRF24L01+ Tutorial. There is an example of a master communicating with 2 slaves that could be extended to a much larger number of slaves.

...R

Thank you Mr Robin2. I was read the tutorial. Thats why im asking again.

Im using this to addressing the TX & RX

......
const uint64_t pipes1 = 0xF0F0F0F0E1LL;
const uint64_t pipes2 = 0xF0F0F0F0E2LL;
....

and add this to writing pipes

.......
  radio.begin();

radio.openWritingPipe(pipes1);
radio.openWritingPipe(pipes2);
}
......

The problem is no communicate between TX & all RX, but if I remove "radio.openWritingPipe(pipes2);' line
Its works normally. but just with RX1.

Where I did wrong?

FoxPerr:
Thank you Mr Robin2. I was read the tutorial. Thats why im asking again.

[.....]

Where I did wrong?

Have you tried my example code completely unchanged?
Did it work?

Wireless problems can be very difficult to debug so get the wireless part working on its own before you start adding any other features.

...R

Sorry Mr. Robin. I try your example and Its working great. Sorry waste your time with my stupid questions. I succesfully compiling and testing your example. I will try my best to do this.
And you right

"Two or three hours spent thinking and reading documentation solves most programming problems"