X-Git-Url: http://git.piffa.net/web?a=blobdiff_plain;f=esempi%2Fbase_th%2Fbase_th.ino;fp=esempi%2Fbase_th%2Fbase_th.ino;h=0bb90e6ca1e77c553d67566b516b22d4a84ebdf2;hb=e9b0b744f9163dac319022d1b2552f49fe1e6bc0;hp=430c94d89ad744ed625dd45764d9070111ef04fb;hpb=8ad30ab0dc403bb19c8554cad53fa5296fc61b91;p=aerei diff --git a/esempi/base_th/base_th.ino b/esempi/base_th/base_th.ino index 430c94d..0bb90e6 100644 --- a/esempi/base_th/base_th.ino +++ b/esempi/base_th/base_th.ino @@ -20,24 +20,24 @@ byte thr ; // Throttle int thrIn ; void setup() { - // I PINs vengono impostati dal constructor al momento - // della dichiarazione dell'ogetto. + // I PINs vengono impostati dal constructor al momento + // della dichiarazione dell'ogetto. - right.Invert() ; // Opzionale: inverte l'ordine del lampeggio da - // HI -> LOW --> LOW -> HI - // per avere 2 LED che lampeggiano alternativamente + right.Invert() ; // Opzionale: inverte l'ordine del lampeggio da + // HI -> LOW --> LOW -> HI + // per avere 2 LED che lampeggiano alternativamente } void loop() { // Lettura CH3 - thrIn = pulseIn(thrPin, HIGH, 25000); - thr = constrain(map(thrIn, 983, 2000, 0, 255), 0, 255) ; - - + thrIn = pulseIn(thrPin, HIGH, 25000); + if (thrIn != 0 && ailIn > 983 && ailIn < 2000) { // clean up + thr = map(thrIn, 983, 2000, 0, 255); // mappato su 8bit per PWM + } // Attivazione LEDs - left.Blink(1120 - 4 * thr); - right.Blink(1120 - 4 * thr); - sotto.lSet(thr); // Luminosita' proporzionale al throttle - delay(10); // Opzionale -} + left.Blink(100 + thr); + right.Blink(100 + thr); + sotto.lSet(thr); // Luminosita' proporzionale al throttle + delay(10); // Opzionale + }