Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <nRF905.h>
- #include <SPI.h>
- #define RXADDR {0xFE, 0x4C, 0xA6, 0xE5} // Address of this device (4 bytes)
- #define TXADDR {0x58, 0x6F, 0x2E, 0x10} // Address of device to send to (4 bytes)
- #define TIMEOUT 1000 // 1 second ping timeout
- void setup()
- {
- // Start up
- nRF905_init();
- // Set address of this device
- byte addr[] = RXADDR;
- nRF905_setRXAddress(addr);
- // Put into receive mode
- nRF905_receive();
- Serial.begin(9600);
- Serial.println(F("Client started"));
- }
- void loop()
- {
- static byte counter;
- // Make data
- char data[NRF905_MAX_PAYLOAD] = {0};
- sprintf(data, "Hello World %hhu", counter);
- counter++;
- // Set address of device to send to
- byte addr[] = TXADDR;
- nRF905_setTXAddress(addr);
- // Set payload data
- nRF905_setData(data, sizeof(data));
- // Send payload (send fails if other transmissions are going on, keep trying until success)
- while(!nRF905_send());
- Serial.println("Hello world sent!")
- delay(1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement