Line 39... |
Line 39... |
39 |
} |
39 |
} |
40 |
|
40 |
|
41 |
void loop() |
41 |
void loop() |
42 |
{ |
42 |
{ |
43 |
int n; |
43 |
int n; |
44 |
unsigned int Motor, Rudder, Check, Check2; |
44 |
unsigned char Motor, Rudder, Check, Check2; |
45 |
|
45 |
|
46 |
char* buf = (char*) _rx_buffer; |
46 |
char* buf = (char*) _rx_buffer; |
47 |
|
47 |
|
48 |
rf01_rxdata(_rx_buffer, 3); |
48 |
rf01_rxdata(_rx_buffer, 3); |
49 |
Serial.print(buf); |
49 |
// Serial.print(buf); |
50 |
Serial.print(' '); |
50 |
// Serial.print(' '); |
51 |
|
51 |
|
52 |
Motor=_rx_buffer[0]; |
52 |
Motor=_rx_buffer[0]; |
53 |
Motor-=(Motor>'9')?('a'-10):'0'; |
- |
|
54 |
Serial.print(Motor, DEC); Serial.print(' '); |
53 |
// Serial.print(Motor, DEC); Serial.print(' '); |
55 |
Rudder=_rx_buffer[1]; |
54 |
Rudder=_rx_buffer[1]; |
56 |
Rudder-=(Rudder>'9')?('a'-10):'0'; |
- |
|
57 |
Serial.print(Rudder, DEC); Serial.print(' '); |
55 |
// Serial.print(Rudder, DEC); Serial.print(' '); |
58 |
Check=_rx_buffer[2]; |
56 |
Check=_rx_buffer[2]; |
59 |
Check-=(Check>'9')?('a'-10):'0'; |
- |
|
60 |
Serial.print(Check, DEC); Serial.print(' '); |
57 |
// Serial.print(Check, DEC); Serial.print(' '); |
61 |
|
58 |
|
62 |
Check2=Motor+Rudder; |
59 |
Check2=Motor+Rudder; |
63 |
if (Check2>32) Check2-=32; |
- |
|
64 |
if (Check!=Check2) |
60 |
if (Check!=Check2) |
- |
|
61 |
{ |
65 |
{Serial.print(' Error');} |
62 |
// {Serial.print(Check2,DEC);} |
- |
|
63 |
} |
66 |
else |
64 |
else |
67 |
{ |
65 |
{ |
68 |
servo_motor.write(Motor); |
66 |
servo_motor.write(Motor+45); |
69 |
servo_rudder.write(Rudder); |
67 |
servo_rudder.write(Rudder/2+45); |
70 |
} |
68 |
} |
71 |
|
69 |
|
- |
|
70 |
delay(15); |
72 |
Serial.println(); |
71 |
// Serial.println(); |
73 |
} |
72 |
} |