/Designs/duckweed_collector/SW/duckweed_rx/duckweed_rx.pde
41,32 → 41,33
void loop()
{
int n;
unsigned char Motor, Rudder, Check, Check2;
unsigned int Motor, Rudder, Check, Check2;
char* buf = (char*) _rx_buffer;
 
rf01_rxdata(_rx_buffer, 3);
// Serial.print(buf);
// Serial.print(' ');
Serial.print(buf);
Serial.print(' ');
Motor=_rx_buffer[0];
// Serial.print(Motor, DEC); Serial.print(' ');
Motor-=(Motor>'9')?('a'-10):'0';
Serial.print(Motor, DEC); Serial.print(' ');
Rudder=_rx_buffer[1];
// Serial.print(Rudder, DEC); Serial.print(' ');
Rudder-=(Rudder>'9')?('a'-10):'0';
Serial.print(Rudder, DEC); Serial.print(' ');
Check=_rx_buffer[2];
// Serial.print(Check, DEC); Serial.print(' ');
Check-=(Check>'9')?('a'-10):'0';
Serial.print(Check, DEC); Serial.print(' ');
Check2=Motor+Rudder;
if (Check2>32) Check2-=32;
if (Check!=Check2)
{
// {Serial.print(Check2,DEC);}
}
{Serial.print(' Error');}
else
{
servo_motor.write(Motor+45);
servo_rudder.write(Rudder/2+45);
servo_motor.write(Motor);
servo_rudder.write(Rudder);
}
 
delay(15);
// Serial.println();
Serial.println();
}
/Designs/duckweed_collector/SW/duckweed_tx/duckweed_tx.pde
34,10 → 34,10
 
void loop()
{
unsigned char _tx_buffer[]="mrc";
unsigned char _tx_buffer[]="aab\0";
unsigned int Motor;
unsigned int Rudder;
unsigned char Check;
unsigned int Check;
signed int ble;
Motor = analogRead(A0);
45,15 → 45,20
 
Motor = MotorOffset - Motor;
Rudder = 512 - ((RudderOffset - Rudder)<<2);
Motor>>=2;
Rudder>>=2;
if (Motor>200) Motor=0;
if (Rudder>250) Rudder=0;
Motor>>=4;
Rudder>>=5;
 
if (Motor>32) Motor=0;
if (Rudder>32) Rudder=0;
Check=Motor+Rudder;
_tx_buffer[0]=(unsigned char)Motor;
_tx_buffer[1]=(unsigned char)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));