ATMEGA328P: Using nRF24L01 transciever to setoff a voltage on the reciever

Hiya!

So my goal is to have a transceiver send out data to a receiver so that when it is received, the receiver will tell it's atmega328P to send out a HIGH to certain pins its connected to, e.g speaker and led will go off that's connected

the transmitter will also be connected to a atmega328P which will be reading a voltage from a ultrasonic sensor reading distance (code i have), e.g when certain distance is detected it will send a voltage to the chip and if its a certain voltage the atmega328P will tell the transmitter to send out data to the receiver letting it know time to trigger those LED, speaker

hope that cleared up what i am trying to do
my main focus is figuring out the communication part of these transceivers, for this application. i have the rest of the code ready and plan to just fill in the blanks once i can get this transceiver code to work

to keep things simple, just having the transciever send data to let the reciever know to have its atmega328P output a HIGH on one of the pins

this is the code i have so far, would you please assist me, thank you

code for transmitter

//RECIEVER
#include <SPI.h>
#include "RF24.h" // libary for transreciever

RF24 myRadio (7, 8);

#include <SPI.h>  
#include "RF24.h"byte addresses[][6] = {"0"}; //this is the "pipe" to communicate with each other

struct package // data 
{
  
};

typedef struct package Package;
Package data;

void setup()
{
  Serial.begin(115200);
  delay(1000);
  myRadio.begin();  
  myRadio.setChannel(115); // up to 126 channels, pick one to communicate
  myRadio.setPALevel(RF24_PA_MAX); //maximum transmitting power = more range
  myRadio.setDataRate( RF24_250KBPS ) ; // lowest data rate, more range
  myRadio.openWritingPipe( addresses[0]);
  delay(1000);
}
void loop()
{
  myRadio.write(&data, sizeof(data)); 

  Serial.print("\nPackage:");
  Serial.print(data.id);
  Serial.print("\n");
  
  delay(1000);

}

code for receiver

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

RF24 myRadio (7, 8);

struct package
{
  
};
byte addresses[][6] = {"0"}; 

typedef struct package Package;
Package data;

void setup() 
{
  Serial.begin(115200);
  delay(1000);

  myRadio.begin(); 
  myRadio.setChannel(115); 
  myRadio.setPALevel(RF24_PA_MAX);
  myRadio.setDataRate( RF24_250KBPS ) ; 
  myRadio.openReadingPipe(1, addresses[0]);
  myRadio.startListening();
}

void loop()  
{

  if ( myRadio.available()) 
  {
    while (myRadio.available())
    {
      myRadio.read( &data, sizeof(data) );
    }
    
  }

}

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

There is also a connection test program to check that the Arduino can talk to the nRF24 it is connected to.

...R