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