Guest User

Untitled

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

×