Hi Good Morning I'm here stuck with a problem......
- Actually I want to make a project in which one Nrf24l01 receiver & three Nrf24l01 transmitter.
** In each transmitter there is a push button & in receiver there is one LED.
*** Now the Project is to ON the receiver LED when any transmitter push button is pressed .
**** when I upload the below code on a single Transmitter & Receiver the circuit runs OK. but when I upload the code on 2nd transmitter & operate its Push-button the LED flicker.
Please Help
Kiran Mahapatra
---------------Receiver Code-------------------
#include <RF24.h>
#include <RF24Network.h>
#include <SPI.h>
#define led 3
RF24 radio(10, 9); // nRF24L01 (CE,CSN)
RF24Network network(radio); // Include the radio in the network
const uint16_t this_node = 00; // Address of this node in Octal format ( 04,031, etc)
void setup() {
SPI.begin();
radio.begin();
network.begin(90, this_node); //(channel, node address)
pinMode(led, OUTPUT);
}
void loop() {
network.update();
while ( network.available() ) { // Is there any incoming data?
RF24NetworkHeader header;
unsigned long buttonState;
network.read(header, &buttonState, sizeof(buttonState)); // Read the incoming data
digitalWrite(led, !buttonState); // Turn on or off the LED
}
}
------------------Transmitter 1--------------
#include <RF24.h>
#include <RF24Network.h>
#include <SPI.h>
#define led 3
RF24 radio(10, 9); // nRF24L01 (CE,CSN)
RF24Network network(radio); // Include the radio in the network
const uint16_t this_node = 00; // Address of this node in Octal format ( 04,031, etc)
void setup() {
SPI.begin();
radio.begin();
network.begin(90, this_node); //(channel, node address)
pinMode(led, OUTPUT);
}
void loop() {
network.update();
while ( network.available() ) { // Is there any incoming data?
RF24NetworkHeader header;
unsigned long buttonState;
network.read(header, &buttonState, sizeof(buttonState)); // Read the incoming data
digitalWrite(led, !buttonState); // Turn on or off the LED
}
}
--------------------Transmitter2----------------------
#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
#define button 2
RF24 radio(10, 9); // nRF24L01 (CE,CSN)
RF24Network network(radio); // Include the radio in the network
const uint16_t this_node = 02; // Address of this node in Octal format ( 04,031, etc)
const uint16_t master00 = 00;
void setup() {
SPI.begin();
radio.begin();
network.begin(90, this_node); //(channel, node address)
}
void loop() {
network.update();
unsigned long buttonState = digitalRead(button);
RF24NetworkHeader header4(master00); // (Address where the data is going)
bool ok3 = network.write(header4, &buttonState, sizeof(buttonState)); // Send the data
}
Moderator edit:
</mark> <mark>[code]</mark> <mark>
</mark> <mark>[/code]</mark> <mark>
tags added.
