/*
connections arduino RF01 and RF02

in arduino version 018
(not yet tested in more recent arduino versions)

tested with ATmega 328
on frequency 433

no range test done yet, just in one room
*/

//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>

int wissel = 0;//wissel means change in dutch

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);
}

 void ledBlink(int num){
   digitalWrite(num, HIGH);
   delay(100);
   digitalWrite(num, LOW);
   delay(100);
 }

unsigned int ble='a';

void loop() 
{
 
//  ledBlink(4);
  
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();
}