3 Nota: rovedere i PWM per come calcolano le pause:
4 non possono schendere sotto a 1ms
8 enum states_available { // Stati della FMS
9 idle, // Throttle a zero
13 states_available state ;
15 // Due LED con lampeggio alternato:
16 Lampeggiatore right = 3;
17 Lampeggiatore left = 5;
20 const byte thrPin = A3;
32 left.Invert() ; // Parte da stato invertito rispetto al default
33 pinMode(rtail, OUTPUT);
34 pinMode(ltail, OUTPUT);
35 pinMode(thrPin, INPUT);
36 // Warning: serial breaks PWM
37 // Serial.begin(9600);
39 randomSeed(analogRead(0));
44 thrIn = pulseIn(thrPin, HIGH, 25000);
45 thr = constrain(map(thrIn, 983, 2000, 0, 255), 0, 255) ;
46 // Inserire necro delay
47 delay(10); // Se si abilita il serial debug
53 } else if ( thr > 245 ) {
61 rwhite.UD(2); // Utilizza il coseno
62 lwhite.UD(2); // Bisognerebbe evitare di calcolarlo 4 volte uguale
68 // Due LED con lampeggio alternato:
69 right.Blink(1120 - 4 * thr );
70 left.Blink(1120 - 4 * thr );
71 analogWrite(rtail, lum(thr));
72 analogWrite(ltail, lum(thr));
76 pausa = random(30, 125);
77 // Due LED con lampeggio alternato:
78 right.Blink(1120 - 4 * thr );
79 digitalWrite(ltail, !digitalRead(ltail));
80 digitalWrite(3, !digitalRead(3));
83 left.Blink(1120 - 4 * thr );
84 digitalWrite(rtail, !digitalRead(rtail));
85 digitalWrite(5, !digitalRead(5));
91 // Serial.println(thrIn);
92 // Serial.print("\t thr:");
94 // Serial.print("\t state:");
95 // Serial.println(state);