Unable to compare char from radio (RF24) The code below is receiver code using nRF24L01. In the loop section I'm comparing the char that was being sent from the Arduino transmitter. In this case the char array says "I'm off" just like the char array compare below. Even though the text is the same, it does not do what it is supposed to do.

Basically the if function below does not seem to work for some reason, both are char arrays (the text[32] and compare[32]) and both will have the same value which is "I'm off" yet it is not registered as the same thing. I cannot figure out what is wrong with the code, please help.

This is the receiver code. The question is about the if function in the loop below.

#include &lt;SPI.h&gt;
#include &lt;nRF24L01.h&gt;
#include &lt;RF24.h&gt;

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] = "";
    char compare[32] = "I'm off";
    radio.read(&amp;text, sizeof(text));
    Serial.println(text);
    Serial.println(compare);
    // this is the problem  --&gt;
    if (text == compare) {
      // it is supposed to print this but it does not --&gt;
      Serial.println("not on");
    }
  }
}


This is the transmitter code

#include &lt;SPI.h&gt;
#include &lt;nRF24L01.h&gt;
#include &lt;RF24.h&gt;
RF24 radio(7, 8); // CNS, CE
const byte address[6] = "00001";
const int button = 5;

void setup() {
  radio.begin();
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MIN);
  radio.stopListening();
  pinMode(button,INPUT);
}

void loop() {
  int reading = digitalRead(button);
  if(reading == HIGH) {
    // send a message to the radio
    const char text[] = "I'm on";
    radio.write(&amp;text, sizeof(text));
    delay(1000);
  }
  if(reading == LOW) {
    // send a message to the radio
    const char text[] = "I'm off";
    radio.write(&amp;text, sizeof(text));
    delay(1000);
  }
}
That is not a good way to solve it.  That is a hack.  The String class does bad things on microcontrollers and it is something you should try to stay away from.  What you need to compare two char arrays is the strcmp function.  

if(strcmp(someCharArray, anotherCharArray) == 0){
    // the strings are the same
}


Use google to find out more about strcmp.