/Designs/duckweed_collector/SW/RF02/RF02.pde
1,38 → 1,81
/*
RF02 TX sample for Arduino
connections arduino RF01 and RF02
 
in arduino version 022
in arduino version 018
(not yet tested in more recent arduino versions)
 
tested with MLAB modules with ATmega 328 at 16MHz
see RF02 library for a Band and Frequency
tested with ATmega 328
on frequency 433
 
no range test done yet, just in one room
*/
 
//connections RF02: (TX)
// SDI, -> RF02 Atmega PB0 Arduino 8 cannot be changed
// SCK, -> RF02 Atmega PB1 Arduino 9 cannot be changed
// nSEL, -> RF02 Atmega PB2 Arduino 10 cannot be changed
// nIRQ, <- RF02 Atmega PB4 Arduino 12 cannot be changed
// FSK: Pullupto VCC
//connections RF02: (sending)
#define SDI 0 // SDI, -> RF02 Atmega PB0 Arduino 8 cannot be changed
#define SCK 1 // SCK, -> RF02 Atmega PB1 Arduino 9 cannot be changed
#define CS 2 // nSEL, -> RF02 Atmega PB2 Arduino 10 cannot be changed
#define IRQ 4 // nIRQ, <- RF02 Atmega PB4 Arduino 12 cannot be changed
//------------------// FSK: Pullupto VCC
 
 
// RF02 sending words
// tested with lib, november 2010
 
#include <RF02.h>
#include <stdint.h>
 
void setup()
{
Serial.begin(9600);
Serial.println("\nSTM02 init" );
int wissel = 0;//wissel means change in dutch
 
void setup() {
rf02_prepAll();
 
Serial.println("done" );
Serial.begin(9600);
Serial.print("hello" );
Serial.println("init" );
rf02_prepAll();
Serial.println("done" );
pinMode(4, OUTPUT); //testing leds
pinMode(5, OUTPUT);
ledBlink(4);
ledBlink(5);
}
 
void ledBlink(int num){
digitalWrite(num, HIGH);
delay(100);
digitalWrite(num, LOW);
delay(100);
}
 
unsigned int ble='a';
 
void loop()
{
unsigned char _tx_buffer[]="0123456789";
delay(1000);
// ledBlink(4);
rf02_txdata( _tx_buffer, sizeof(_tx_buffer));
delay(1000);
 
// unsigned char buf[] = { "01234567890123456789012345678901\n" }; // Motor, Rudder
unsigned char buf[] = { "0123456789012345678$0123456789" };
 
unsigned char sum=0;
//buf[19]=ble;
for(unsigned int a=0;a<20;a++)
{
sum+=buf[a];
};
if(ble>'z') {ble='a';} else {ble++;}
buf[20]=sum;
buf[21]=0xAA;
buf[22]=0xAA;
rf02_changeText( buf, 23);
 
// rf02_changeText( buf, sizeof buf);
// Serial.println("M0R0\n");
rf02_sendData();
}