4 2 LED / Strisce laterali che lampeggiano alternativamente
5 1 LED / Striscia sotto in FADE
7 Lettura del canale Throttle (3) con la funzione Pulsein
13 Lampeggiatore left = 10;
14 Lampeggiatore right = 11;
17 // Quando il Throttle e' in IDE facciamo un PWM anche sui laterali
22 const byte thrPin = 3; // PIN collegato al CH3
23 int thrIn ; // Valore rilevato del 3 Ch della RX
24 int thr ; // Valore a 16bit per il throttle
25 byte thrBit ; // Valore a 8bit per il throttle
26 const int thMin = 983; // In genere il valore minimo del TH resta costante,
27 // per calcolarlo si puo' usare la funzione di calibrazione nel setup
32 // I PINs vengono impostati dal constructor al momento
33 // della dichiarazione dell'ogetto.
35 right.Invert() ; // Opzionale: inverte l'ordine del lampeggio da
36 // HI -> LOW --> LOW -> HI
37 // per avere 2 LED che lampeggiano alternativamente
39 randomSeed(analogRead(0));
43 // Lettura CH3 con pulsein, per usare interrupts vedi ../snippets.
44 thrIn = pulseIn(thrPin, HIGH, 25000);
45 if (thrIn >= thMin && thrIn < 2000) { // clean up
56 else if (thr > 1900) {
57 // Throttle al massimo: LED laterali lampeggiano a caso,
58 // Sotto luminosita' a caso
59 caso = random(30, 250) ;
67 thrBit = map(thr,1050, 1900, 0, 255);
68 right.Blink(1220 - 4 * thrBit );
69 left.Blink(1220 - 4 * thrBit );
70 sotto.lSet(thrBit)); // Luminosita' proporzionale al throttle