Rev Author Line No. Line
2139 kakl 1 /*
2 RF02 TX duckweed collector
3  
4 in arduino version 022
5  
6 tested with MLAB modules with ATmega 328 at 16MHz
7 see RF02 library for a Band and Frequency
8 */
9  
10 //connections RF02: (TX)
11 // SDI, -> RF02 Atmega PB0 Arduino 8 cannot be changed
12 // SCK, -> RF02 Atmega PB1 Arduino 9 cannot be changed
13 // nSEL, -> RF02 Atmega PB2 Arduino 10 cannot be changed
14 // nIRQ, <- RF02 Atmega PB4 Arduino 12 cannot be changed
15 // FSK: Pullupto VCC
16  
17 #include <RF02.h>
18  
19 unsigned int MotorOffset;
20 unsigned int RudderOffset;
21  
22 void setup()
23 {
24 Serial.begin(9600);
25 Serial.println("\nSTM02 init" );
26  
27 MotorOffset = analogRead(A0);
28 RudderOffset = analogRead(A1);
29  
30 rf02_prepAll();
31  
32 Serial.println("done" );
33 }
34  
35 void loop()
36 {
2141 kakl 37 unsigned char _tx_buffer[]="mrc";
2139 kakl 38 unsigned int Motor;
39 unsigned int Rudder;
2141 kakl 40 unsigned char Check;
2139 kakl 41 signed int ble;
42  
43 Motor = analogRead(A0);
44 Rudder = analogRead(A1);
45  
46 Motor = MotorOffset - Motor;
47 Rudder = 512 - ((RudderOffset - Rudder)<<2);
2141 kakl 48 Motor>>=2;
49 Rudder>>=2;
50 if (Motor>200) Motor=0;
51 if (Rudder>250) Rudder=0;
2139 kakl 52  
53 Check=Motor+Rudder;
2141 kakl 54  
55 _tx_buffer[0]=(unsigned char)Motor;
56 _tx_buffer[1]=(unsigned char)Rudder;
2139 kakl 57 _tx_buffer[2]=Check;
58  
59 rf02_txdata( _tx_buffer, sizeof(_tx_buffer));
60 }
61  
62