/Designs/duckweed_collector/SW/duckweed_rx/duckweed_rx.pde |
---|
0,0 → 1,45 |
/* |
RF02 TX duckweed collector |
in arduino version 022 |
tested with MLAB modules with ATmega 328 at 16MHz |
see RF02 library for a Band and Frequency |
*/ |
//connections RF01: (RX) |
// RF01 SDI, arduino 13, ATmega PB5, cannot be changed |
// RF01 SCK, arduino 12, ATmega PB4, cannot be changed |
// RF01 nSEL, arduino 11, ATmega PB3, cannot be changed |
// RF01 SDO, arduino 10, ATmega PB2, cannot be changed |
// RF01 niRQ, arduino 02, ATmega PD2, cannot be changed |
// RF01 nFFS: 1-10k Pullup too Vcc |
// receiving words with RF01 |
#include <RF01.h> |
void setup() |
{ |
Serial.begin(9600); |
Serial.println("\nRFM01 init"); |
delay(250); |
rf01_prepAll(); |
Serial.println("done"); |
} |
void loop() |
{ |
int n; |
char* buf = (char*) _rx_buffer; |
rf01_rxdata(_rx_buffer, 10); |
buf[11]=0; |
Serial.println(buf); |
for(n=0;n<32;n++) {Serial.print(buf[n], HEX); Serial.print(' ');} |
Serial.println(); |
} |
/Designs/duckweed_collector/SW/duckweed_tx/duckweed_tx.pde |
---|
0,0 → 1,67 |
/* |
RF02 TX duckweed collector |
in arduino version 022 |
tested with MLAB modules with ATmega 328 at 16MHz |
see RF02 library for a Band and Frequency |
*/ |
//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 |
#include <RF02.h> |
unsigned int MotorOffset; |
unsigned int RudderOffset; |
void setup() |
{ |
Serial.begin(9600); |
Serial.println("\nSTM02 init" ); |
MotorOffset = analogRead(A0); |
RudderOffset = analogRead(A1); |
rf02_prepAll(); |
Serial.println("done" ); |
} |
void loop() |
{ |
unsigned char _tx_buffer[]="aab\0"; |
unsigned int Motor; |
unsigned int Rudder; |
unsigned int Check; |
signed int ble; |
Motor = analogRead(A0); |
Rudder = analogRead(A1); |
Motor = MotorOffset - Motor; |
Rudder = 512 - ((RudderOffset - Rudder)<<2); |
Motor>>=4; |
Rudder>>=5; |
if (Motor>32) Motor=0; |
if (Rudder>32) Rudder=0; |
Check=Motor+Rudder; |
if (Check>32) Check-=32; |
Motor+=(Motor>9)?('a'-10):'0'; |
Rudder+=(Rudder>9)?('a'-10):'0'; |
Check+=(Check>9)?('a'-10):'0'; |
_tx_buffer[0]=Motor; |
_tx_buffer[1]=Rudder; |
_tx_buffer[2]=Check; |
rf02_txdata( _tx_buffer, sizeof(_tx_buffer)); |
} |
/Designs/duckweed_collector/SW/library/RF01/RF01.cpp |
---|
49,7 → 49,7 |
for (unsigned char i=0; i<11; i++) _delay_ms(10); // wait until POR done |
rf01_trans(0x0000); |
rf01_trans(0x0000); // cargo cult settings |
rf01_trans(0x8000|0x1000|0x70|0x02); //band |
rf01_trans(0xA640); // freq |
rf01_trans(0xC823); //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 9600 Bd |