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=430c94d89ad744ed625dd45764d9070111ef04fb;hb=32041f442197b78fab52a297a1b5e71ef6eb16a3;hp=0000000000000000000000000000000000000000;hpb=ad6370083abcb50cbedafd46e5b6cd1a20a078d9;p=aerei diff --git a/esempi/base_th/base_th.ino b/esempi/base_th/base_th.ino new file mode 100644 index 0000000..430c94d --- /dev/null +++ b/esempi/base_th/base_th.ino @@ -0,0 +1,43 @@ +/* Esempio + + Esempio base: + 2 LED / Strisce laterali che lampeggiano alternativamente + 1 LED / Striscia sotto in FADE + + Lettura del canale Throttle (3) con la funzione Pulsein +*/ + +#include + +// LED disponibili +Lampeggiatore left = 12; +Lampeggiatore right = 11; +Pwm sotto = 9; + +// Variabili +const byte thrPin = 3; // PIN collegato al CH3 +byte thr ; // Throttle +int thrIn ; + +void setup() { + // 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 +} + +void loop() { +// Lettura CH3 + thrIn = pulseIn(thrPin, HIGH, 25000); + thr = constrain(map(thrIn, 983, 2000, 0, 255), 0, 255) ; + + + +// Attivazione LEDs + left.Blink(1120 - 4 * thr); + right.Blink(1120 - 4 * thr); + sotto.lSet(thr); // Luminosita' proporzionale al throttle + delay(10); // Opzionale +}