Hi,
today I am using two modules NRF24L01. I connected them to Arduino Uno and Arduino Nano. Both has Atmega 328P. I made a program based on https://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo
And it looks like that:
TRANSMIT
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CE_PIN 9
#define CSN_PIN 10
#define greenled 2
const uint64_t pipe = 0xE8E8F0F0E1LL;
RF24 radio(CE_PIN, CSN_PIN);
int led[1];
void setup()
{
pinMode(greenled, OUTPUT);
Serial.begin(9600);
delay(1000);
Serial.println("Nrf24L01 Receiver Starting");
radio.begin();
radio.openReadingPipe(1,pipe);
radio.startListening();
}
void loop()
{
if ( radio.available() )
{
bool done = false;
while (!done)
{
done = radio.read( led, sizeof(led) );
if(led[0] == 1)
{
digitalWrite(greenled, HIGH);
}
if(led[0] == 0)
{
digitalWrite(greenled, LOW);
}
}
}
else
{
delay(500);
Serial.println("No radio available");
}
}
RECEIVE
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CE_PIN 9
#define CSN_PIN 10
#define greenled 2
const uint64_t pipe = 0xE8E8F0F0E1LL;
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
int led[1];
void setup()
{
pinMode(greenled, OUTPUT);
Serial.begin(9600);
delay(1000);
Serial.println("Nrf24L01 Receiver Starting");
radio.begin();
radio.openReadingPipe(1,pipe);
radio.startListening();
}
void loop()
{
if ( radio.available() )
{
bool done = false;
while (!done)
{
// Fetch the data payload
done = radio.read( led, sizeof(led) );
if(led[0] == 1)
{
digitalWrite(greenled, HIGH);
}
if(led[0] == 0)
{
digitalWrite(greenled, LOW);
}
}
}
else
{
delay(500);
Serial.println("No radio available");
}
}
When I turn both arduino on, "Receive Arduino" returns "No radio available" to Serial Monitor.
I don't know how to repair that.
Any ideas?
Thanks for answers!