RF24L01 and motor connected. Get char from RF24L01 and run a motor.

Hello everyone! I would like to get a message and compare it to . The transmitter is working properly, but the receiver only gets message and transmit it over Serial. I want to get message directly from received text.

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8); // CE, CSN
const byte address[6] = "00001";

/**************************
 MOTOR PARAMETERS
**************************/

const int pinMA1=2;
const int pinMA2=3;
const int Enable1=4;
float val=255;

void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MAX);
  radio.startListening();

/******************************
MOTOR PIN CONFIGURATION 
*******************************/
  pinMode(pinMA1, OUTPUT);
  pinMode(pinMA2, OUTPUT); 
  pinMode(Enable1, OUTPUT);
  digitalWrite(pinMA1, LOW);
  digitalWrite(pinMA2, LOW);
  analogWrite(Enable1, 0);

}
void loop() {
  if (radio.available()) {
    char text[12] = "";
    radio.read(&text, sizeof(text));
    Serial.println(text);
    
    if(text=="HELLO WORLD"){
      
  Serial.println("forward A");
  digitalWrite(pinMA1, HIGH);
  digitalWrite(pinMA2, LOW);
  analogWrite(Enable1, val);
  delay(6000);    
}
}
}

Thank you!

Have a look at this Simple nRF24L01+ Tutorial.

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

The examples are as simple as I could make them and they have worked for other Forum members. If you get stuck it will be easier to help with code that I am familiar with. Start by getting the first example to work

...R

    char text[12] = "";
    radio.read(&text, sizeof(text));
    Serial.println(text);
   
    if(text=="HELLO WORLD"){

text is NOT a string, so you should not be passing it to a function that expects a string.

Learn what makes a char array a string (Hint: There MUST be a NULL terminator), and make text a string BEFORE you pass it to a function that expects a string.

Learn how to compare strings, too. The == operator is NOT the way.

PaulS:
Learn how to compare strings, too. The == operator is NOT the way.

When using Cstrings you must use strcmp() to compare values rather than ==

...R