I built a project using 2 x nRF24LO1 modules with adaptor and it worked fas intended, the sounder gave a variable tone and the LED went on and off. For some reason it has stopped working and I tried with two new nRF24LO1s but to no avail. I have looked through the sketches but can't find anything wrong and I have checked and checked the wiring and all appears to be well. I am tearing out what little hair I have left and would appreciate some fresh eyes to see if they can see my error(s). the Transmitter and receiver sketches are as follows:
The Receiver Sketch
#include <TimerOne.h>
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define relayPin A0
int buttonState = 0;
int redLED = 2;
RF24 radio(7, 8); // CE, CSN
// SCK - Pin 13, MOSI - Pin 11 & MISO - Pin 12
const byte address[6] = "00002";
// ISR Function
void blinkLED() {
digitalWrite(redLED, !digitalRead(redLED));
}
// Standard setup
void setup() {
Serial.begin(9600);
pinMode(relayPin, OUTPUT);
pinMode(redLED, OUTPUT);
digitalWrite(relayPin, LOW);
radio.begin();
radio.openReadingPipe(0, address);
radio.setPALevel(RF24_PA_MIN);
}
// Standard Loop
void loop() {
radio.startListening();
while (!radio.available());
radio.read(&buttonState, sizeof(buttonState));
Serial.println(buttonState);
if (buttonState == 1) {
for (int a=0; a<=10; a++) {
for (int i=1000; i<=1050; i++) {
tone(relayPin, i, 100);
delay(10);
interrupts();
Timer1.initialize(75000);
Timer1.attachInterrupt(blinkLED);
}
}
}
else
{
digitalWrite(relayPin, LOW);
noInterrupts();
digitalWrite(redLED, LOW);
}
}
and the transmitter sketch is
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define buttonPin A0
int buttonState = 0;
RF24 radio(7, 8); // CE, CSN
// SCK - Pin 13, MOSI - Pin 11 & MISO - Pin 12
const byte address[6] = "00002";
void setup() {
pinMode(buttonPin, INPUT_PULLUP);
Serial.begin(9600);
radio.begin();
radio.openWritingPipe(address);
radio.setPALevel(RF24_PA_MIN);
radio.stopListening();
}
void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState == 1)
{
buttonState = 0;
}
else if (buttonState == 0)
{
buttonState = 1;
}
Serial.println(buttonState);
radio.write(&buttonState, sizeof(buttonState));
delay(50);
}
The transmitter sketch serial monitor shows the button state, but the receiver sketch serial monitor returns -10024 constantly. Photos show both units.
in both cases the CE pin is connected to pin 7, the CSN to pin 8, the SCK to pin 13, the MO to pin 11 and the M1 to pin 12. LED is on pin 2 and the buzzer(relayPin) is on pin A0


