Programming NRF24LO1

Hi !
I am a newbie and learning NRF24LO1 transceiver n in many of the tutorials, I've seen a line of code,

radio.read(&text, sizeof(text));

Like in this program and many others,

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8); // CNS, CE
const byte address[6] = "00001";
void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MIN);
  radio.startListening();
}
void loop() {
  if (radio.available()) {
    char text[32] = "";
    radio.read(&text, sizeof(text));
    Serial.println(text);

so.. Kindly explain the components of the line like,
~why there is a & in start
~why i have to write "sizeof"

and also guide me how to read characters from [radio.read] and convert it into something like,,

if radio.read is equal to a given character suppose "A",then DigitalWrite(pin1, HIGH) and if radio.read is "B" then DigitalWrite(pin2, HIGH)
...
THANKS (and sorry if my question is stupid :confused: )

  1. Mean address of. Have a look at pointer in C++ :slight_smile:

  2. Because the function needs to know the size of the array. An array is just a pile of variables ordered after each other in memory. But once you point something to a array it needs to know where the pile ends.

Um.....thanks a lot! :slight_smile:

but.. what about the few lines in the bottom of my question????

If .read() returns a char (no idea) then

char in = radio.read();
if(in == 'A'){
  digitalWrite(pin1, HIGH);
}
else if(in == 'B'){
  digitalWrite(pin2, HIGH);
}

But you have to check what read() gives you. Never used the NRF24L01 that way :smiley:

No0oB:
and also guide me how to read characters from [radio.read] and convert it into something like,,

if radio.read is equal to a given character suppose "A",then DigitalWrite(pin1, HIGH) and if radio.read is "B" then DigitalWrite(pin2, HIGH)

radio.read is a function. It is not equal to a given character. It places (copies) the packet from the
nRF24L01 chip into a memory buffer you supply (here called text).

You then look at whats in the buffer.

///radio.read is a function. It is not equal to a given character. It places (copies) the packet from the
nRF24L01 chip into a memory buffer you supply (here called text).
You then look at whats in the buffer.
///

I got it! (y)
So whats the solution?

If you're only interested in if that package starts with a 'A' or a 'B', simply check the first char of that array against a 'A' or a 'B' like I showed you.

Okay...THANKS MAN!!

:slight_smile:

This Simple nRF24L01+ Tutorial may be of interest.

...R