]> git.piffa.net Git - aerei/blobdiff - esempi/base_th/base_th.ino
CLean up ssl
[aerei] / esempi / base_th / base_th.ino
index 430c94d89ad744ed625dd45764d9070111ef04fb..0bb90e6ca1e77c553d67566b516b22d4a84ebdf2 100644 (file)
@@ -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
+    }