#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
byte addresses[][
6
] = {
"1Node"
,
"2Node"
};
RF24
radio
(2,15)
;
bool
radioNumber =
0
;
bool
role =
1
;
/**********************************************************/
void
setup
()
{
Serial.begin(
115200
);
Serial.println(F(
"RF24/examples/GettingStarted"
));
Serial.println(F(
"*** PRESS 'R' to begin receiving from the other node"
));
radio.begin();
radio.setChannel(
108
);
radio.setPALevel(RF24_PA_MIN);
if
(radioNumber){
radio.openWritingPipe(addresses[
1
]);
radio.openReadingPipe(
1
,addresses[
0
]);
}
else
{
radio.openWritingPipe(addresses[
0
]);
radio.openReadingPipe(
1
,addresses[
1
]);
}
radio.startListening();
}
void
loop
()
{
/****************** Ping Out Role ***************************/
if
(role ==
1
) {
radio.stopListening();
Serial.println(F(
"Now sending"
));
unsigned
long
start_time = micros();
//radio.write( &start_time, sizeof(unsigned long));
if
(!radio.write( &start_time,
sizeof
(
unsigned
long
) )){
Serial.println(F(
"failed"
));
25 / 51
NodeMCU
Summary of Contents for nRF24L01
Page 3: ...3 51...
Page 4: ...Introduction 4 51...
Page 7: ...Pin Map 7 51...
Page 9: ...Preparation Getting Started 9 51...
Page 11: ...RF24 Library 11 51...
Page 12: ...RF24 Library 12 51...
Page 13: ...First Node NodeMCU 13 51...
Page 14: ...First Node NodeMCU 14 51...
Page 15: ...Second Node Nano 15 51...
Page 16: ...Second Node Nano 16 51...
Page 17: ...Code Play Getting Started 17 51...
Page 18: ...Simple Transmit Receive NodeMCU Transmit Nano Receive Ref Example Sketches 18 51...
Page 23: ...RF24 Sample Code 23 51...
Page 24: ...RF24 Sample Code GettingStarted 24 51...
Page 30: ...Simple Remote Control 30 51...
Page 31: ...NodeMCU Remote Controller 31 51...
Page 32: ...Nano Local Controller 32 51...
Page 33: ...Simple Remote Control 33 51...
Page 38: ...Simple Remote Control 38 51...
Page 39: ...Nano Attach a Device 39 51...
Page 40: ...Nano Attach a Device 40 51...
Page 41: ...Connecting to Blynk Cloud Gateway 41 51...
Page 44: ...Blynk Button with Virtual Pin V1 44 51...
Page 46: ...Refs Resources 46 51...
Page 48: ...NodeMCU V1 0 Pin Map 48 51...
Page 49: ...Nano V3 0 Pin Map 49 51...
Page 50: ...Nano V3 0 Pin Map 50 51...