Code for switching

I am very new to arduino, but I am familiar with electricity. I am trying to use multiple arduino’s with rf transmitters to control some lights. Basically, I want to have one unit that is rx only, supplying control for 2 different lights. I will have 2 other arduinos at separate locations attached to buttons. Ultimately, I would like 1 central unit that use relays to power 2 separate lights. The button for each light would be at at two separate locations, so a specific light turning on would indicate which button was pressed to trigger it. I am having trouble with the code for the radio portion. At this point I am just trying to get 2 units to work before adding the third. Code below, any help is appreciated.

TX:

#include <SPI.h>

#include <nRF24L01.h>

#include <RF24.h>

RF24 radio (7,8);

const byte address [6]= (“00001”);

const int SWITCH = 3;

int STATE = 0;

void setup() {

radio.begin();

radio.openWritingPipe(address); // 00001

radio.setPALevel(RF24_PA_MIN);

pinMode (SWITCH, INPUT);

// put your setup code here, to run once:

}

void loop() {

radio.stopListening ();

STATE = digitalRead (SWITCH);

radio.write (&STATE, sizeof(STATE));}

// put your main code here, to run repeatedly:

RX:

#include <SPI.h>

#include <nRF24L01.h>

#include <RF24.h>

RF24 radio (7,8);

const byte address [6]= (“00001”);

const int LED = 4;

int STATE = 0;

void setup() {

radio.begin();

radio.openReadingPipe(0,address); // 00001

radio.setPALevel(RF24_PA_MIN);

pinMode (LED, OUTPUT);

// put your setup code here, to run once:

}

void loop() {

radio.startListening ();

while (!radio.available());

radio.read (STATE, sizeof(STATE));

if (STATE == HIGH)

{

digitalWrite (LED, HIGH);

}

else

{digitalWrite (LED, LOW);

}}

Have you managed to get the radios to talk to each other at all? To start with, I'd forget the lights and switches in favor of just sending single characters to the other arduino and having it echo them to Serial. I'd hope that the examples that come with your library would include such a thing.

This excellent tutorial may help you to get the radios to work.