Hi, I recently got my arduinos working with a very simple rf sender and transmitter, but decided to upgrade to a pair of NRF24L01's, and the programming seems simple enough, but am I missing something?
I have set my transmitter up like this:
int inputs[4];
RF24 radio(7, 8);
const byte address[6] = "00001";
void setup()
{
Serial.begin(9600);
radio.begin();
radio.openWritingPipe(address);
radio.setPALevel(RF24_PA_MIN);
radio.stopListening();
}
void loop() {
/*various stuff for getting inputs*/
radio.write(&inputs, sizeof(inputs));
for (byte i = 0; i < 4; i++)
{
Serial.println(inputs[i]);
}
Serial.println("----");
delay(2000);
}
The serial monitor displays it's getting and storing my inputs the way I expect, but have I sent the data the correct way?
This is my receiver:
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
int inputs[4];
RF24 radio(9, 10); // CE, CSN
const byte address[6] = "00001";
void setup()
{
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(0, address);
radio.setPALevel(RF24_PA_MIN);
radio.startListening();
}
void loop()
{
radio.read(&inputs, sizeof(inputs));
if (radio.available())
{
for (byte i = 0; i < 4; i++)
{
Serial.println(inputs[i]);
}
Serial.println("----");
}
}
It finds the radio signal, but all the values in the array stay at 0 instead of mirroring the output of the transmitter, any ideas? It's definitely picking up the signal of the transmitter, but I seem to have made a mistake in actually transferring the data.