Guest User

Untitled

a guest
Sep 19th, 2015
202
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <nRF905.h>
  2. #include <SPI.h>
  3.  
  4. #define RXADDR {0x58, 0x6F, 0x2E, 0x10} // Address of this device (4 bytes)
  5. #define TXADDR {0xFE, 0x4C, 0xA6, 0xE5} // Address of device to send to (4 bytes)
  6.  
  7. void setup()
  8. {
  9.     // Start up
  10.     nRF905_init();
  11.    
  12.     // Set address of this device
  13.     byte addr[] = RXADDR;
  14.     nRF905_setRXAddress(addr);
  15.  
  16.     // Put into receive mode
  17.     nRF905_receive();
  18.  
  19.     Serial.begin(9600);
  20.  
  21.     Serial.println(F("Server started"));
  22. }
  23.  
  24. void loop()
  25. {
  26.     Serial.println(F("Waiting for data..."));
  27.  
  28.     // Make buffer for data
  29.     byte buffer[NRF905_MAX_PAYLOAD];
  30.  
  31.     // Wait for data
  32.     while(!nRF905_getData(buffer, sizeof(buffer)));
  33.  
  34.     // Put back into receive mode
  35.     nRF905_receive();
  36.  
  37.     Serial.println(F("Got data"));
  38.  
  39.     // Print out ping contents
  40.     Serial.print(F("Data: "));
  41.     Serial.write(buffer, sizeof(buffer));
  42.     Serial.println();
  43. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×