2 * le funzioni finali sono da controllare
8 enum states_available { // Stati della FMS
9 idle, // Throttle a zero
13 states_available state ;
15 // Due LED con lampeggio alternato:
16 Lampeggiatore right = 3;
17 Lampeggiatore left = 5;
20 const byte thrPin = A3;
31 left.Invert() ; // Parte da stato invertito rispetto al default
32 pinMode(rtail, OUTPUT);
33 pinMode(ltail, OUTPUT);
34 pinMode(thrPin, INPUT);
35 // Warning: serial breaks PWM
38 randomSeed(analogRead(0));
43 thrIn = pulseIn(thrPin, HIGH, 25000);
44 thr = constrain(map(thrIn, 983, 2000, 0, 255), 0, 255) ;
49 } else if ( thr > 245 ) {
64 // Due LED con lampeggio alternato:
65 right.Blink(1120 - 4 * thr );
66 left.Blink(1120 - 4 * thr );
67 analogWrite(rtail, thr);
68 analogWrite(ltail, thr);
72 // Due LED con lampeggio alternato:
73 right.Blink(1120 - 4 * thr );
74 left.Blink(1120 - 4 * thr );
75 digitalWrite(rtail, !digitalRead(rtail));
76 digitalWrite(ltail, !digitalRead(ltail));
77 delay(random(20, 100));
82 Serial.println(thrIn);
83 Serial.print("\t thr:");
85 Serial.print("\t state:");
86 Serial.println(state);