SHOW:
|
|
- or go back to the newest paste.
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 | } |