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