6 2 LED PWM ai lati con lampeggio alternato
7 2 LED PWM alle estremita ali
10 2 interrupts per th e alettone
16 * Vedere la calibrazione automatica
17 * Min e max a 1000 - 2000 per alettone
24 // Instanziamo un LED fuori dal loop
25 Lampeggiatore left = 6;
26 Lampeggiatore right = 9;
27 Lampeggiatore codasx = 5;
28 Lampeggiatore codadx = 10;
35 // Variabili per interrupt 0 si PIN 2
36 volatile unsigned int chValue2 = 1500; // Valore computato
37 volatile unsigned int chStart2 = 1500; // Inizio rilevamento
39 // Variabili per interrupt 1 su PIN 3
40 volatile unsigned int chValue3 = 1500; // Valore computato
41 volatile unsigned int chStart3 = 1500; // Inizio rilevamento
43 // Variabili per autocalibrazione 0
44 const byte chPin2 = 2; // PIN per la calibrazione alettone
45 int mid_point2 = 1500;
47 // Variabili per autocalibrazione 1
48 const byte chPin3 = 3; // PIN per la calibrazione
49 int mid_point3 = 1000;
53 // I PINs vengono impostati dal constructor al momento
54 // della dichiarazione dell'ogetto.
58 // HI -> LOW --> LOW -> HI
59 // per avere 2 LED che lampeggiano alternativamente
60 // Funzione relativa a calibrazione con pulsein:
61 //mid_point2 = calibraTrim(chPin2) ; // Calibrazione del TRIM attivo sul canale
62 //mid_point3 = calibraTrim(chPin3) ; // Calibrazione del TRIM attivo sul canale
63 attachInterrupt(0, chRise2, RISING); // PIN 2 su 328p / 168
64 attachInterrupt(1, chRise3, RISING); // PIN 3 su 328p / 168
77 Serial.print("PIN2: ");
78 Serial.print(chValue2);
79 Serial.print(" -base: ");
80 Serial.print(mid_point2);
82 Serial.print(" |-| PIN3:");
83 Serial.print(chValue3);
84 Serial.print(" -base: ");
85 Serial.println(mid_point3);
91 attachInterrupt(0, chFall2, FALLING);
96 attachInterrupt(0, chRise2, RISING);
97 chValue2 = micros() - chStart2;
101 attachInterrupt(1, chFall3, FALLING);
106 attachInterrupt(1, chRise3, RISING);
107 chValue3 = micros() - chStart3;