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