You are on page 1of 6

Transmitter:-

#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
RF24 radio(7, 8); // nRF24L01 (CE,CSN)
RF24Network network(radio); // Include the
radio in the network
const uint16_t node01 = 01; // Address of our node
in Octal format ( 04,031, etc)
const uint16_t master00 = 00; // Address of the
other node in Octal format
const unsigned long interval = 10; //ms // How
often to send data to the other unit
unsigned long last_sent; // When did we last
send?
void setup() {
Serial.begin(9600);
SPI.begin();
radio.begin();
network.begin(90, node01); //(channel, node
address)
radio.setPALevel(RF24_PA_MIN);
radio.stopListening();
}
void loop() {
int output_value = analogRead(A0);

output_value = map(output_value,550,0,0,100);
Serial.println(output_value);
delay(1000);
RF24NetworkHeader header(master00); //
(Address where the data is going)
bool ok = network.write(header, &output_value,
sizeof(output_value)); // Send the data
delay(1000);
}

RECIEVER:-
#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
RF24 radio(3,4); // 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)
const uint16_t node01 = 01; // Address of the
other node in Octal format
#include<LiquidCrystal.h> //
Including lcd display library
LiquidCrystal lcd (5,6,7,8,9,10); // Define
LCD display pins RS,E,D4,D5,D6,D7
void setup() {
SPI.begin();
radio.begin();
network.begin(90, this_node); //(channel, node
address)
radio.setPALevel(RF24_PA_MIN);
radio.startListening();
lcd.begin(16,2); // setting LCD
as 16x2 type
lcd.setCursor(0,0);
lcd.print("my work");
lcd.setCursor(0,1);
lcd.print("ArduinoInterrupt");
delay(3000);
lcd.clear();
}

void loop() {
network.update();
if( network.available() )
{ while( network.available() )// Is there any
incoming data?

{
delay(10);
RF24NetworkHeader header(node01);
int incomingData;
network.read(header, &incomingData,
sizeof(incomingData)); // Read the incoming data
Serial.print("1:");
Serial.println("interrupt");
lcd.setCursor(0,1);
lcd.print("Interrupt 1");
delay(3000);
lcd.clear();
}
}

You might also like