Line 32... |
Line 32... |
32 |
Serial.println("done" ); |
32 |
Serial.println("done" ); |
33 |
} |
33 |
} |
34 |
|
34 |
|
35 |
void loop() |
35 |
void loop() |
36 |
{ |
36 |
{ |
37 |
unsigned char _tx_buffer[]="aab\0"; |
37 |
unsigned char _tx_buffer[]="mrc"; |
38 |
unsigned int Motor; |
38 |
unsigned int Motor; |
39 |
unsigned int Rudder; |
39 |
unsigned int Rudder; |
40 |
unsigned int Check; |
40 |
unsigned char Check; |
41 |
signed int ble; |
41 |
signed int ble; |
42 |
|
42 |
|
43 |
Motor = analogRead(A0); |
43 |
Motor = analogRead(A0); |
44 |
Rudder = analogRead(A1); |
44 |
Rudder = analogRead(A1); |
45 |
|
45 |
|
46 |
Motor = MotorOffset - Motor; |
46 |
Motor = MotorOffset - Motor; |
47 |
Rudder = 512 - ((RudderOffset - Rudder)<<2); |
47 |
Rudder = 512 - ((RudderOffset - Rudder)<<2); |
48 |
Motor>>=4; |
48 |
Motor>>=2; |
49 |
Rudder>>=5; |
49 |
Rudder>>=2; |
- |
|
50 |
if (Motor>200) Motor=0; |
- |
|
51 |
if (Rudder>250) Rudder=0; |
50 |
|
52 |
|
51 |
if (Motor>32) Motor=0; |
- |
|
52 |
if (Rudder>32) Rudder=0; |
- |
|
53 |
Check=Motor+Rudder; |
53 |
Check=Motor+Rudder; |
54 |
if (Check>32) Check-=32; |
- |
|
55 |
|
- |
|
56 |
Motor+=(Motor>9)?('a'-10):'0'; |
- |
|
57 |
Rudder+=(Rudder>9)?('a'-10):'0'; |
- |
|
58 |
Check+=(Check>9)?('a'-10):'0'; |
- |
|
59 |
|
54 |
|
60 |
_tx_buffer[0]=Motor; |
55 |
_tx_buffer[0]=(unsigned char)Motor; |
61 |
_tx_buffer[1]=Rudder; |
56 |
_tx_buffer[1]=(unsigned char)Rudder; |
62 |
_tx_buffer[2]=Check; |
57 |
_tx_buffer[2]=Check; |
63 |
|
58 |
|
64 |
rf02_txdata( _tx_buffer, sizeof(_tx_buffer)); |
59 |
rf02_txdata( _tx_buffer, sizeof(_tx_buffer)); |
65 |
} |
60 |
} |
66 |
|
61 |
|