Am wanting to add 2 way comms between 2 Mega boards.
I have the NRF24L01 modules, and am about to complete the wiring on a breadboard.
My sketch requires that the RF pipe is monitored while the rest of the sketch continues to loop.
Had a look at the PingPair example that came with the rf24 library and have coded as follows ( not yet tested ) :
rfDataArrived = 0;
if ( radio.available() ){
bool done = false;
while (!done){
done = radio.read( &duino2, sizeof(duino2) );
// do something with the variables and commands received in the duino2 struct
if(duino2.mType == 1) rfDataArrived = 1;
}
radio.stopListening();
if(duino2.mType == 1){ // this is new incoming data - not a ping back
delay(50); // short delay so sender can change back to listening
duino2.mType = 2; // change the mType flag to a ping reply data type - so other receiver does not process it.
radio.write( &duino2, sizeof(duino2) ); // ping back the data received
radio.startListening();
}
}
, but I don't seem to find an answer to the following :
- would a sketch stop executing ( looping ) if it is listening for a radio signal, or would it only pause for a short while when radio data starts to arrive ?
or should this be changed to detect the INT pin on the radio connected to the Arduino interrupt pin/s ?
Regards