1 /* Throttle state machine
3 Idle, throttle e averburner effect basati sono sul canale throttle.
10 enum { // Stati della FMS
11 idle, // Throttle a zero
16 // Due LED con lampeggio alternato:
17 Lampeggiatore right = 3;
18 Lampeggiatore left = 5;
21 const byte thrPin = A3;
22 byte thr ; // Valore a 8bit per il throttle
23 int thrIn ; // Valore rilevato del 3 Ch della RX
28 left.Invert() ; // Parte da stato invertito rispetto al default
29 randomSeed(analogRead(0));
34 // Lettura Throttle channel: FAKE con un potenziometro
35 //thrIn = analogRead(3);
36 //thr = constrain(thrIn / 4 , 0, 255) ;
38 // Lettura Throttle channel
39 thrIn = pulseIn(thrPin, HIGH, 25000);
40 thr = constrain(map(thrIn, 983, 2000, 0, 255), 0, 255) ; // 983 potrebbe campbiare con
41 // con un altra ricevente, fare una calibrazione nel caso.
46 } else if ( thr > 245 ) {
54 // Lampeggia i lati fissi e fa un PWD Up/Down col motore
61 // right e left lampeggiano alternativamente in base al th,
62 // il motore e' acceso con correzione di luminosita' in proporzione al th
63 right.Blink(1120 - 4 * thr ); // lampeggio piu' rapido in base al Th
64 left.Blink(1120 - 4 * thr );
69 // lampeggi e PWM a caso
72 motore.lSet(random(0,255);
73 delay(random(20, 100));