/*
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(57600);
        Serial.print("hello" );
        Serial.println("init" );
 
      
        rf02_prepAll434();
        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);
 }
 

void loop() {
 
        ledBlink(4);
  
        delay(1550);
        Serial.print(wissel );
      Serial.println(" send: ");
        
 
        switch ( wissel)
        {
                case 0:
                {
                        unsigned char buf[] = { "hello World!   \n" };
                        rf02_changeText( buf, sizeof buf);
                        Serial.println("hello World!    \n");
                        rf02_sendData();
                        wissel = 1;
                        break;
                }
                 case 1:
                {
                        unsigned char buf[] = { "Goodbye Life!   \n" };
                        Serial.println("Goodbye Life!   \n");
                        rf02_changeText( buf, sizeof buf);
                        rf02_sendData();
                        wissel =  2;
                        break;
                }
                 case 2:
                {
                        unsigned char buf[] = { "Bless all!      \n" };
                        Serial.println("Bless all!      \n");
                        rf02_changeText( buf, sizeof buf);
                        rf02_sendData();
                        wissel =  0;
                        break;
                }
        }
}