First of all, id like to explain what i want to build.I would like to build a systtem which has 1 RECEİVER 2 TRANSMİTTER i have 3 arduino uno and 3 nRF24L01 wireless rf modules. 1 RECEİVER has 2 leds for TRANSMİTTERs.When it gets the data from the transmitter it lights up the led.This is very simple communication example. i have done it 1-1 communication but it became complex when i try it for 1-2 communication.
i have a problem with programming part which makes me very nervous.
let me share my code of RECEİVER
#include <SPI.h> //Call SPI library so you can communicate with the nRF24L01+
#include <nRF24L01.h> //nRF2401 libarary found at https://github.com/tmrh20/RF24/
#include <RF24.h> //nRF2401 libarary found at https://github.com/tmrh20/RF24/
const int pinCE = 9; //This pin is used to set the nRF24 to standby (0) or active mode (1)
const int pinCSN = 10; //This pin is used to tell the nRF24 whether the SPI communication is a command or message to send out
RF24 wirelessSPI(pinCE, pinCSN); // Declare object from nRF24 library (Create your wireless SPI)
const uint64_t rAddress[] = {0xB00B1E50D2LL, 0xB00B1E50C3LL}; //Create pipe addresses for the 2 nodes to recieve data, the "LL" is for LongLong type
const uint64_t wAddress[] = {0xB00B1E50B1LL, 0xB00B1E50A4LL}; //Create pipe addresses for the 2 nodes to transmit data, the "LL" is for LongLong type
int LED1 = 3;
int LED2 = 6;
int msg[1];
int msg1[1];
void setup()
{
Serial.begin(9600); //start serial to communication
wirelessSPI.begin(); //Start the nRF24 module
wirelessSPI.openReadingPipe(1,rAddress[0]); //open pipe o for recieving meassages with pipe address
wirelessSPI.openReadingPipe(2,rAddress[1]); //open pipe o for recieving meassages with pipe address
wirelessSPI.startListening();
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
}
void loop()
{
if(wirelessSPI.available()){
bool done = false;
bool done1= false;
while (!done){
done = wirelessSPI.read( msg, 1 );
done1 = wirelessSPI.read(msg1,1);
if((msg[0] == 111)&&(msg1[0]== 222)){
digitalWrite(LED1,HIGH);
digitalWrite(LED2,HIGH);
}
// else if((msg[0] != 111)||(msg1[0] == 222)){
// digitalWrite(LED2,HIGH);
// digitalWrite(LED1,LOW);
// }
// else{ digitalWrite(LED2,LOW);
// digitalWrite(LED1,LOW);}
}}}
and i have the transmitter codes that i really wanted to keep it simple somehow
TRANSMİTTER 1
//***************************Arduino Code for Transmitter 1****************************
#include <SPI.h> //Call SPI library so you can communicate with the nRF24L01+
#include <nRF24L01.h> //nRF2401 libarary found at https://github.com/tmrh20/RF24/
#include <RF24.h> //nRF2401 libarary found at https://github.com/tmrh20/RF24/
const int pinCE = 9; //This pin is used to set the nRF24 to standby (0) or active mode (1)
const int pinCSN = 10; //This pin is used to tell the nRF24 whether the SPI communication is a command or message to send out
byte counter = 1; //used to count the packets sent
bool done = false; //used to know when to stop sending packets
RF24 wirelessSPI(pinCE, pinCSN); // Create your nRF24 object or wireless SPI connection
const uint64_t wAddress = 0xB00B1E50D2LL; // Pipe to write or transmit on
const uint64_t rAddress = 0xB00B1E50B1LL; //pipe to receive data on
int msg[1];
void setup()
{
Serial.begin(9600); //start serial to communicate process
wirelessSPI.begin(); //Start the nRF24 module
wirelessSPI.openWritingPipe(wAddress); //open writing or transmit pipe
//wirelessSPI.openReadingPipe(1,rAddress); //open reading or recieve pipe
//wirelessSPI.stopListening(); //go into transmit mode
}
void loop()
{
while(1){
msg[0]=111;
wirelessSPI.write(msg, 1);
}
}
TRANSMİTTER 2
//Arduino Code for Transmitter 1*
#include <SPI.h> //Call SPI library so you can communicate with the nRF24L01+
#include <nRF24L01.h> //nRF2401 libarary found at https://github.com/tmrh20/RF24/
#include <RF24.h> //nRF2401 libarary found at https://github.com/tmrh20/RF24/
const int pinCE = 9; //This pin is used to set the nRF24 to standby (0) or active mode (1)
const int pinCSN = 10; //This pin is used to tell the nRF24 whether the SPI communication is a command or message to send out
byte counter = 1; //used to count the packets sent
bool done = false; //used to know when to stop sending packets
RF24 wirelessSPI(pinCE, pinCSN); // Create your nRF24 object or wireless SPI connection
const uint64_t wAddress = 0xB00B1E50D2LL; // Pipe to write or transmit on
const uint64_t rAddress = 0xB00B1E50B1LL; //pipe to recive data on
int msg[1];
void setup()
{
Serial.begin(9600); //start serial to communicate process
wirelessSPI.begin(); //Start the nRF24 module
wirelessSPI.openWritingPipe(wAddress); //open writing or transmit pipe
//wirelessSPI.openReadingPipe(1,rAddress); //open reading or recieve pipe
//wirelessSPI.stopListening(); //go into transmit mode
}
void loop()
{
while(1){
msg[0]=222;
wirelessSPI.write(msg, 1);
}
}
any idea would be great. Thanks in advance !