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 RF02: (sending) |
|
|
14 |
#define SDI 0 // SDI, -> RF02 Atmega PB0 Arduino 8 cannot be changed |
|
|
15 |
#define SCK 1 // SCK, -> RF02 Atmega PB1 Arduino 9 cannot be changed |
|
|
16 |
#define CS 2 // nSEL, -> RF02 Atmega PB2 Arduino 10 cannot be changed |
|
|
17 |
#define IRQ 4 // nIRQ, <- RF02 Atmega PB4 Arduino 12 cannot be changed |
|
|
18 |
//------------------// FSK: Pullupto VCC |
|
|
19 |
|
|
|
20 |
|
|
|
21 |
// RF02 sending words |
|
|
22 |
// tested with lib, november 2010 |
|
|
23 |
|
|
|
24 |
#include <RF02.h> |
|
|
25 |
#include <stdint.h> |
|
|
26 |
|
|
|
27 |
int wissel = 0;//wissel means change in dutch |
|
|
28 |
|
|
|
29 |
void setup() { |
|
|
30 |
|
|
|
31 |
Serial.begin(57600); |
|
|
32 |
Serial.print("hello" ); |
|
|
33 |
Serial.println("init" ); |
|
|
34 |
|
|
|
35 |
|
|
|
36 |
rf02_prepAll434(); |
|
|
37 |
Serial.println("done" ); |
|
|
38 |
|
|
|
39 |
pinMode(4, OUTPUT); //testing leds |
|
|
40 |
pinMode(5, OUTPUT); |
|
|
41 |
ledBlink(4); |
|
|
42 |
ledBlink(5); |
|
|
43 |
} |
|
|
44 |
|
|
|
45 |
void ledBlink(int num){ |
|
|
46 |
digitalWrite(num, HIGH); |
|
|
47 |
delay(100); |
|
|
48 |
digitalWrite(num, LOW); |
|
|
49 |
delay(100); |
|
|
50 |
} |
|
|
51 |
|
|
|
52 |
|
|
|
53 |
void loop() { |
|
|
54 |
|
|
|
55 |
ledBlink(4); |
|
|
56 |
|
|
|
57 |
delay(1550); |
|
|
58 |
Serial.print(wissel ); |
|
|
59 |
Serial.println(" send: "); |
|
|
60 |
|
|
|
61 |
|
|
|
62 |
switch ( wissel) |
|
|
63 |
{ |
|
|
64 |
case 0: |
|
|
65 |
{ |
|
|
66 |
unsigned char buf[] = { "hello World! \n" }; |
|
|
67 |
rf02_changeText( buf, sizeof buf); |
|
|
68 |
Serial.println("hello World! \n"); |
|
|
69 |
rf02_sendData(); |
|
|
70 |
wissel = 1; |
|
|
71 |
break; |
|
|
72 |
} |
|
|
73 |
case 1: |
|
|
74 |
{ |
|
|
75 |
unsigned char buf[] = { "Goodbye Life! \n" }; |
|
|
76 |
Serial.println("Goodbye Life! \n"); |
|
|
77 |
rf02_changeText( buf, sizeof buf); |
|
|
78 |
rf02_sendData(); |
|
|
79 |
wissel = 2; |
|
|
80 |
break; |
|
|
81 |
} |
|
|
82 |
case 2: |
|
|
83 |
{ |
|
|
84 |
unsigned char buf[] = { "Bless all! \n" }; |
|
|
85 |
Serial.println("Bless all! \n"); |
|
|
86 |
rf02_changeText( buf, sizeof buf); |
|
|
87 |
rf02_sendData(); |
|
|
88 |
wissel = 0; |
|
|
89 |
break; |
|
|
90 |
} |
|
|
91 |
} |
|
|
92 |
} |
|
|
93 |
|
|
|
94 |
|