1 /* Zeta senza state machine
3 Gestione del Throttle con ciclo condizionale.
10 // Due LED con lampeggio alternato:
11 Lampeggiatore right = 3;
12 Lampeggiatore left = 5;
15 const byte thrPin = A3;
20 left.Invert() ; // Parte da stato invertito rispetto al default
21 pinMode(rtail, OUTPUT);
22 pinMode(ltail, OUTPUT);
23 pinMode(thrPin, INPUT);
24 // Serial.begin(9600);
26 randomSeed(analogRead(0));
30 thrIn = pulseIn(thrPin, HIGH, 25000);
31 thr = constrain(map(thrIn, 983, 2000, 0, 255), 0, 255) ;
33 if (thr >0 && thr < 15) {
34 digitalWrite(rtail, 1);
35 digitalWrite(ltail, 1);
39 } else if (thr < 245) {
40 // Due LED con lampeggio alternato:
41 right.Blink(1120 - 4 * thr );
42 left.Blink(1120 - 4 * thr );
43 analogWrite(rtail, thr);
44 analogWrite(ltail, thr);
46 digitalWrite(rtail, !digitalRead(rtail));
47 digitalWrite(ltail, !digitalRead(ltail));
48 delay(random(20, 100));
54 Serial.println(thrIn);
55 Serial.print("\t thr:");