/Designs/duckweed_collector/SW/RF02/RF02.pde
1,81 → 1,38
/*
connections arduino RF01 and RF02
RF02 TX sample for Arduino
 
in arduino version 018
(not yet tested in more recent arduino versions)
in arduino version 022
 
tested with ATmega 328
on frequency 433
 
no range test done yet, just in one room
tested with MLAB modules with ATmega 328 at 16MHz
see RF02 library for a Band and Frequency
*/
 
//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
//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
 
 
// RF02 sending words
// tested with lib, november 2010
 
#include <RF02.h>
#include <stdint.h>
 
int wissel = 0;//wissel means change in dutch
void setup()
{
Serial.begin(9600);
Serial.println("\nSTM02 init" );
rf02_prepAll();
 
void setup() {
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);
Serial.println("done" );
}
 
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";
// ledBlink(4);
delay(1000);
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();
rf02_txdata( _tx_buffer, sizeof(_tx_buffer));
}