Advertisement
Guest User

Receiver

a guest
Jun 10th, 2015
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.86 KB | None | 0 0
  1. #include <RF24Network.h>
  2. #include <RF24.h>
  3. #include <SPI.h>
  4. #include <printf.h>
  5.  
  6.  
  7. // nRF24L01(+) radio attached to SPI and pins 8 & 9
  8. RF24 radio(9,10);
  9.  
  10. // Network uses that radio
  11. RF24Network network(radio);
  12.  
  13. // Address of our node
  14. const uint16_t this_node = 0;
  15.  
  16. // Address of the other node
  17. const uint16_t other_node = 1;
  18.  
  19. void setup(void)
  20. {
  21.   Serial.begin(9600);
  22.   printf_begin();
  23.   SPI.begin();
  24.   radio.begin();
  25.   network.begin(/*channel*/ 90, /*node address*/ this_node);
  26. }
  27.  
  28. void loop(void)
  29. {
  30.   // Pump the network regularly
  31.   network.update();
  32.  
  33.   // Is there anything ready for us?
  34.   while ( network.available() )
  35.   {
  36.     // If so, grab it and print it out
  37.     RF24NetworkHeader header;
  38.     static char message[32];
  39.     network.read(header,message,sizeof(message));
  40.     Serial.print("Received: ");
  41.     Serial.println(message);
  42.   }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement