Guest User

Untitled

a guest
Sep 13th, 2015
167
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. #include <nRF905.h>
  3. #include <SPI.h>
  4.  
  5. #define RXADDR {0xFE, 0x4C, 0xA6, 0xE5} // Address of this device (4 bytes)
  6. #define TXADDR {0x58, 0x6F, 0x2E, 0x10} // Address of device to send to (4 bytes)
  7.  
  8. #define TIMEOUT 1000 // 1 second ping timeout
  9.  
  10. void setup()
  11. {
  12.     // Start up
  13.     nRF905_init();
  14.    
  15.     // Set address of this device
  16.     byte addr[] = RXADDR;
  17.     nRF905_setRXAddress(addr);
  18.  
  19.     // Put into receive mode
  20.     nRF905_receive();
  21.  
  22.     Serial.begin(9600);
  23.    
  24.     Serial.println(F("Client started"));
  25. }
  26.  
  27. void loop()
  28. {
  29.     static byte counter;
  30.  
  31.     // Make data
  32.     char data[NRF905_MAX_PAYLOAD] = {0};
  33.     sprintf(data, "Hello World %hhu", counter);
  34.     counter++;
  35.  
  36.     // Set address of device to send to
  37.     byte addr[] = TXADDR;
  38.     nRF905_setTXAddress(addr);
  39.  
  40.     // Set payload data
  41.     nRF905_setData(data, sizeof(data));
  42.  
  43.     // Send payload (send fails if other transmissions are going on, keep trying until success)
  44.     while(!nRF905_send());
  45.  
  46.     Serial.println("Hello world sent!")
  47.  
  48.     delay(1000);
  49. }
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.

×