controlling one LED with nrf24l01

Hello there arduino community, im new to the forum.
i would like some help with a code im writing using nRf24l01
my code seem to not be working…and it’s been 2 days now

this is the TX code

// setting up the libraries needed for communication
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <RF24_config.h>

// my pins are set up in the standard format in which the RF24 library examples uses

#define CE_PIN   9 
#define CSN_PIN 10

//define the transmit pipe
const uint64_t pipe = 0xE8E8F0F0E1LL;
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio channel to use the CE and CSN pins


int signal[1];
int a = 1;      // you can either intiliaze the data to be sent or just plug it in
int b = 2;     // in the Void Loop section.



void setup(void)
{
  Serial.begin(9600);
  radio.begin();
  radio.openWritingPipe(pipe);
  Serial.println("nRf24L01 is in TX Mode");
  pinMode(led,OUTPUT);
}

//The code that will be running constantly on the TX arduino
void loop(void)
{
  int Radiosignal = Serial.read();
  
  switch(Radiosignal)
   {
     //using letter q to send a signal to turn on the led
     case 'q':
     signal[0] = a; // number "1" is being sent. 
     radio.write( signal, sizeof(signal) ); // this line uses the library to send the value declared above
     Serial.println("message to turn ON the LED is in the radio line");
     break;
     
     //using letter r to send a signal to turn off the led
     case 'r':
     
     signal[0] = b; // number 2 is being sent. 
     radio.write( signal, sizeof(signal) );// this line uses the library to send the value declared above
     Serial.println("message to turn OFF the LED is in the radio line");
     break;
   }
 }

this is the RX code

// setting up the libraries needed for communication
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

#define CE_PIN   9
#define CSN_PIN 10

RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
const uint64_t pipe = 0xE8E8F0F0E1LL;
int signal[1];      // signal consists of 1 channel
int led = 7;

void setup(void)
{
  Serial.begin(9600);
  Serial.println("Nrf24L01 Receiver Starting");
  radio.begin();
  radio.openReadingPipe(1,pipe);
  radio.startListening();
  Serial.println("nRf24L01 is in RX Mode");
  
  pinMode(led,OUTPUT);
  digitalWrite(led,HIGH);
  delay(200);
  digitalWrite(led,LOW);
  delay(200);
}

//The code that will be running constantly on the arduino
void loop(void)
{
  if (radio.available()){
   bool radiosignal = false;
   while (!radiosignal){
     
     radiosignal = radio.read(&signal,sizeof(signal));
     
     Serial.print(signal[0]); // to print the signal received
     
     if (signal[0] == 1) // if the evice receives the value "1"
     {
      digitalWrite(led, HIGH);
      Serial.println("led is turned ON");  
     }
     
     if (signal[0] == 2) // if the device receives the value "2"
     {
      digitalWrite(led, LOW);
      Serial.println("led is turned OFF");  
     }
   }
  }
}

Start with the TX code. Do you see any of the Serial.print() messages ?
What do you see if you print Radiosignal after the Serial input ?

 int Radiosignal = Serial.read();
  
  switch(Radiosignal)
   {
     //using letter q to send a signal to turn on the led
     case 'q':

Radiosignal is an int. Will it ever equal 'q' ?

when i start the serial monitor i get

for TX
"nRf is in TX mode"

for RX
"nRf receiver starting"
"nRf is in RX mode"

and i also change int Radiosignal to char Radiosignal, i didn't realize it because the code was compiling just fine

What do you see if you print Radiosignal after the Serial input in the TX code ?

omg!!! :o i made it work!!! :’( :’(
Thank you so much! thank you ;D
all i did was added the Serial.println() to see if i was receiving anything at the node
which i was not and also changing int Radiosignal, to char Radiosignal and a few more tweaks that came to mind! as i was writing it…oh my god it works my man!

TX

// setting up the libraries needed for communication
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <RF24_config.h>

// my pins are set up in the standard format in which the RF24 library examples uses

#define CE_PIN   9 
#define CSN_PIN 10

//define the transmit pipe
const uint64_t pipe = 0xE8E8F0F0E1LL;
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio channel to use the CE and CSN pins


int signal[1];
int a = 1;      // you can either intiliaze the data to be sent or just plug it in
int b = 0;     // in the Void Loop section.



void setup(void)
{
  Serial.begin(9600);
  radio.begin();
  radio.openWritingPipe(pipe);
  Serial.println("nRf24L01 is in TX Mode");

}

//The code that will be running constantly on the TX arduino
void loop(void)
{
  char Radiosignal = Serial.read();
  
  switch(Radiosignal)
   {
     //using letter q to send a signal to turn on the led
     case 'q':
     signal[0] = a; // number "1" is being sent. 
     radio.powerUp();
     delay(1000);
     signal[0] = radio.write(&signal, sizeof(signal) ); // this line uses the library to send the value declared above
     Serial.println(a);
     Serial.println("message to turn ON the LED is in the radio line");
     radio.powerDown();
     break;
     
     //using letter r to send a signal to turn off the led
     case 'r':
     
     signal[0] = b; // number 0 is being sent. 
     radio.powerUp();
     delay(1000);
     signal[0] = radio.write(&signal, sizeof(signal) );// this line uses the library to send the value declared above
     
     Serial.println(b);
     Serial.println("message to turn OFF the LED is in the radio line");
     radio.powerDown();
     break;
   }
 }

RX

// setting up the libraries needed for communication
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

#define CE_PIN   9
#define CSN_PIN 10

RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
const uint64_t pipe = 0xE8E8F0F0E1LL;
int signal[1];      // signal consists of 1 channel
int led = 7;

void setup(void)
{
  Serial.begin(9600);
  Serial.println("Nrf24L01 Receiver Starting");
  radio.begin();
  radio.openReadingPipe(1,pipe);
  radio.startListening();
  Serial.println("nRf24L01 is in RX Mode");
  
  pinMode(led,OUTPUT);
  digitalWrite(led,HIGH);
  delay(200);
  digitalWrite(led,LOW);
  delay(200);
}

//The code that will be running constantly on the arduino
void loop(void)
{
  if (radio.available()){
   bool radiosignal = false;
   while (!radiosignal){
    
     radiosignal = radio.read(&signal,sizeof(signal));
   
     Serial.println(radiosignal); // to print the signal received
     
     if (signal[0] == 1) // if the evice receives the value "1"
     {
      digitalWrite(led, HIGH);
      Serial.println("led is turned ON");  
     }
     
     if (signal[0] == 0) // if the device receives the value "2"
     {
      digitalWrite(led, LOW);
      Serial.println("led is turned OFF");  
     }
   }
  }
}

I am glad that you got it working. Now what are you going to do ?

Now I'm going to use that to control a relay so that I can control lamps and maybe do more than just switching on and off