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