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;
30 RGBLed rgb(7,8,4,255);
33 left.Invert() ; // Parte da stato invertito rispetto al default
34 pinMode(rtail, OUTPUT);
35 pinMode(ltail, OUTPUT);
36 pinMode(thrPin, INPUT);
37 // Warning: serial breaks PWM
38 // Serial.begin(9600);
40 randomSeed(analogRead(0));
46 thrIn = pulseIn(thrPin, HIGH, 25000);
47 thr = constrain(map(thrIn, 983, 2000, 0, 255), 0, 255) ;
48 // Inserire necro delay
49 delay(10); // Se si abilita il serial debug
55 } else if ( thr > 245 ) {
64 rwhite.UD(2000); // Utilizza il coseno
65 lwhite.UD(2000); // Bisognerebbe evitare di calcolarlo 4 volte uguale
72 // Due LED con lampeggio alternato:
73 right.Blink(1120 - 4 * thr );
74 left.Blink(1120 - 4 * thr );
75 analogWrite(rtail, lum(thr));
76 analogWrite(ltail, lum(thr));
81 pausa = random(30, 125);
82 // Due LED con lampeggio alternato:
83 right.Blink(1120 - 4 * thr );
84 digitalWrite(ltail, !digitalRead(ltail));
85 digitalWrite(3, !digitalRead(3));
88 left.Blink(1120 - 4 * thr );
89 digitalWrite(rtail, !digitalRead(rtail));
90 digitalWrite(5, !digitalRead(5));
96 // Serial.println(thrIn);
97 // Serial.print("\t thr:");
99 // Serial.print("\t state:");
100 // Serial.println(state);