1 |
/* |
1 |
/* |
2 |
connections arduino RF01 and RF02 |
2 |
connections arduino RF01 and RF02 |
3 |
|
3 |
|
4 |
in arduino version 018 |
4 |
in arduino version 018 |
5 |
(not yet tested in more recent arduino versions) |
5 |
(not yet tested in more recent arduino versions) |
6 |
|
6 |
|
7 |
tested with ATmega 328 |
7 |
tested with ATmega 328 |
8 |
on frequency 433 |
8 |
on frequency 433 |
9 |
|
9 |
|
10 |
no range test done yet, just in one room |
10 |
no range test done yet, just in one room |
11 |
*/ |
11 |
*/ |
12 |
|
12 |
|
13 |
//connections RF01: (receiving) |
13 |
//connections RF01: (receiving) |
14 |
#define SDI 5 // RF01 SDI, arduino 13, ATmega PB5, cannot be changed |
14 |
#define SDI 5 // RF01 SDI, arduino 13, ATmega PB5, cannot be changed |
15 |
#define SCK 4 // RF01 SCK, arduino 12, ATmega PB4, cannot be changed |
15 |
#define SCK 4 // RF01 SCK, arduino 12, ATmega PB4, cannot be changed |
16 |
#define CS 3 // RF01 nSEL, arduino 11, ATmega PB3, cannot be changed |
16 |
#define CS 3 // RF01 nSEL, arduino 11, ATmega PB3, cannot be changed |
17 |
#define SDO 2 // RF01 SDO, arduino 10, ATmega PB2, cannot be changed |
17 |
#define SDO 2 // RF01 SDO, arduino 10, ATmega PB2, cannot be changed |
18 |
//--------------------- // RF01 niRQ, arduino 02, ATmega PD2, cannot be changed |
18 |
//--------------------- // RF01 niRQ, arduino 02, ATmega PD2, cannot be changed |
19 |
//----------------------// RF01 nFFS: 1-10k Pullup too Vcc |
19 |
//----------------------// RF01 nFFS: 1-10k Pullup too Vcc |
20 |
|
20 |
|
21 |
|
21 |
|
22 |
// receiving words with RF01 |
22 |
// receiving words with RF01 |
23 |
|
23 |
|
24 |
#include <RF01.h> |
24 |
#include <RF01.h> |
25 |
|
25 |
|
26 |
int serialTesting = 1; |
26 |
int serialTesting = 1; |
27 |
|
27 |
|
28 |
void setup() { |
28 |
void setup() { |
29 |
|
29 |
|
30 |
Serial.begin(9600); |
30 |
Serial.begin(9600); |
31 |
Serial.println("\nRF02 receive"); |
31 |
Serial.println("\nRF02 receive"); |
32 |
delay(250); |
32 |
delay(250); |
33 |
|
33 |
|
34 |
rf01_prepAll(); |
34 |
rf01_prepAll(); |
35 |
|
35 |
|
36 |
delay(250); |
36 |
delay(250); |
37 |
Serial.println("startup"); |
37 |
Serial.println("startup"); |
38 |
} |
38 |
} |
39 |
|
39 |
|
40 |
void loop() { |
40 |
void loop() { |
41 |
int n; |
41 |
int n; |
42 |
// unsigned char buf[] = { "$00\n" }; // Motor, Rudder |
42 |
// unsigned char buf[] = { "$00\n" }; // Motor, Rudder |
43 |
for(n=0;n<32;n++) rf01_data[n]='$'; |
43 |
for(n=0;n<32;n++) rf01_data[n]='$'; |
44 |
rf01_receive(); |
44 |
rf01_receive(); |
45 |
char* buf = (char*) rf01_data; |
45 |
char* buf = (char*) rf01_data; |
46 |
buf[31]=0; |
46 |
buf[31]=0; |
47 |
//if ((buf[0]=='$')&&(buf[3]=='\n')) |
47 |
//if ((buf[0]=='$')&&(buf[3]=='\n')) |
48 |
Serial.println(rf01_data); |
48 |
Serial.println(buf); |
49 |
for(n=0;n<32;n++) {Serial.print(rf01_data[n], HEX); Serial.print(' ');} |
49 |
for(n=0;n<32;n++) {Serial.print(rf01_data[n], HEX); Serial.print(' ');} |
50 |
Serial.println(); |
50 |
Serial.println(); |
51 |
|
51 |
|
52 |
delay(700); |
52 |
delay(10); |
53 |
|
53 |
|
54 |
} |
54 |
} |