Si j ai bien compris, avec ta voie auxiliaire et ses 4 positions et mon bout de code, tu peux largement t en sortir
voila les modes que j ai dans le code fournis:
void loop()
{ // On commence la boucle par la position du switch en ch6 pour la selection des 2 modes ou tout eteindre
duch6 = pulseIn(ch6, HIGH); // duree a l etat haut ch6
// lecture de la valeur ch6:
int sensorReading = pulseIn(ch6, HIGH);
// segmentation de la valeur en 3 positions:
int range = map(sensorReading, sensorMin, sensorMax, 0, 2);
// 3 positions possibles via l etat de ch6
// 0: Off mode, 1: Navigation mode et 2: Ufo mode
switch (range) {
case 0: // Off mode
Serial.println("off");
digitalWrite(ledPin1, LOW); // LED blanc OFF
digitalWrite(ledPin2, LOW); // LED bleu OFF
digitalWrite(ledPin3, LOW); // LED vert OFF
digitalWrite(ledPin4, LOW); // LED orange OFF
digitalWrite(ledPin5, LOW); // LED rouge OFF
digitalWrite(ledPin6, LOW); // LED blanc et rouge navigation OFF
digitalWrite(ledPin7, LOW); // LED blanc pleins phares OFF
digitalWrite(ledPin8, LOW); // LED blanc strobe OFF
digitalWrite(ledPin9, LOW); // LED rouge OFF
digitalWrite(ledPin10, LOW); // LED vert OFF
digitalWrite(ledPin11, LOW); // LED rouge OFF
break;
case 1: // Navigation mode
Serial.println("Navigation mode");
{ // On commence la boucle de la position du potar en ch5 pour la selection des 5 modes navigation
duch5 = pulseIn(ch5, HIGH); // duree a l etat haut ch5
// lecture de la valeur ch5:
int sensorReading = pulseIn(ch5, HIGH);
// segmentation de la valeur en 5 positions:
int range = map(sensorReading, sensorMin, sensorMax, 0, 4);
// 5 positions possibles via l etat de ch5
// 0: Off mode, 1: Takeoff, 2:Flight, 3: Landing et 4: Parking
switch (range) {
case 0: // Off mode
Serial.println("off");
digitalWrite(ledPin1, LOW); // LED blanc OFF
digitalWrite(ledPin2, LOW); // LED bleu OFF
digitalWrite(ledPin3, LOW); // LED vert OFF
digitalWrite(ledPin4, LOW); // LED orange OFF
digitalWrite(ledPin5, LOW); // LED rouge OFF
break;
case 1: // Takeoff light mode
Serial.println("Takeoff");
digitalWrite(ledPin7, HIGH); // LED blanc pleins phares ON
digitalWrite(ledPin9, LOW); // LED rouge ON
digitalWrite(ledPin10, LOW); // LED vert ON
digitalWrite(ledPin11, LOW); // LED rouge ON
digitalWrite(ledPin8, LOW); // LED blanc OFF
digitalWrite(ledPin6, HIGH); // LED blanc et rouge navigation ON
delay (50);
digitalWrite(ledPin6, LOW); // LED blanc et rouge navigation ON
delay (50);
digitalWrite(ledPin6, HIGH); // LED blanc et rouge navigation ON
delay (50);
digitalWrite(ledPin6, LOW); // LED blanc et rouge navigation OFF
delay (50);
delay (200);
break;
case 2: // Flight light mode
Serial.println("Flight");
digitalWrite(ledPin6, LOW); // LED blanc et rouge navigation OFF
digitalWrite(ledPin7, LOW); // LED blanc pleins phares OFF
digitalWrite(ledPin8, LOW); // LED blanc strobe OFF
digitalWrite(ledPin9, LOW); // LED rouge OFF
digitalWrite(ledPin10, LOW); // LED vert OFF
digitalWrite(ledPin11, LOW); // LED rouge OFF
digitalWrite(ledPin9, HIGH); // LED rouge ON
digitalWrite(ledPin10, HIGH); // LED vert ON
digitalWrite(ledPin6, HIGH); // LED blanc et rouge navigation ON
delay (50);
digitalWrite(ledPin8, HIGH); // LED blanc ON
delay (50);
digitalWrite(ledPin8, LOW); // LED blanc OFF
delay (50);
digitalWrite(ledPin6, LOW); // LED blanc et rouge navigation OFF
delay (50);
break;
case 3: // Landing light mode
Serial.println("landing");
digitalWrite(ledPin6, LOW); // LED blanc et rouge navigation OFF
digitalWrite(ledPin7, LOW); // LED blanc pleins phares OFF
digitalWrite(ledPin8, LOW); // LED blanc strobe OFF
digitalWrite(ledPin9, LOW); // LED rouge OFF
digitalWrite(ledPin10, LOW); // LED vert OFF
digitalWrite(ledPin11, LOW); // LED rouge OFF
digitalWrite(ledPin7, HIGH); // LED blanc pleins phares ON
digitalWrite(ledPin9, HIGH); // LED rouge ON
digitalWrite(ledPin10, HIGH); // LED vert ON
digitalWrite(ledPin11, HIGH); // LED rouge ON
digitalWrite(ledPin6, HIGH); // LED blanc et rouge navigation ON
delay (50);
digitalWrite(ledPin8, HIGH); // LED blanc ON
delay (50);
digitalWrite(ledPin8, LOW); // LED blanc OFF
delay (50);
digitalWrite(ledPin6, LOW); // LED blanc et rouge navigation OFF
delay (50);
break;
case 4: // Parking light mode
Serial.println("Parking");
digitalWrite(ledPin6, LOW); // LED blanc et rouge navigation OFF
digitalWrite(ledPin7, LOW); // LED blanc pleins phares OFF
digitalWrite(ledPin8, LOW); // LED blanc strobe OFF
digitalWrite(ledPin9, LOW); // LED rouge OFF
digitalWrite(ledPin10, LOW); // LED vert OFF
digitalWrite(ledPin11, LOW); // LED rouge OFF
digitalWrite(ledPin7, HIGH); // LED blanc pleins phares ON
digitalWrite(ledPin9, HIGH); // LED rouge ON
digitalWrite(ledPin10, HIGH); // LED vert ON
break;
}
}
break;
case 2: // Flight light mode
Serial.println("UFO mode");
{ // On commence la boucle de la position du potar en ch5 pour la selection des 5 modes UFO
duch5 = pulseIn(ch5, HIGH); //calcul de la duree a l etat haut
// lecture de la valeur ch5
int sensorReading = pulseIn(ch5, HIGH);
// segmentation de la valeur en 5 positions:
int range = map(sensorReading, sensorMin, sensorMax, 0, 4);
// 5 positions possibles via l etat de ch5
// 0: Off, 1: 01, 2: 02, 3: 03 et 4: 04
switch (range) {
case 0: // ufo mode Off
Serial.println("off");
digitalWrite(ledPin1, LOW); // LED blanc OFF
digitalWrite(ledPin2, LOW); // LED bleu OFF
digitalWrite(ledPin3, LOW); // LED vert OFF
digitalWrite(ledPin4, LOW); // LED orange OFF
digitalWrite(ledPin5, LOW); // LED rouge OFF
delay (500);
digitalWrite(ledPin1, HIGH); // LED blanc ON
digitalWrite(ledPin2, HIGH); // LED bleu ON
digitalWrite(ledPin3, HIGH); // LED vert ON
digitalWrite(ledPin4, HIGH); // LED orange ON
digitalWrite(ledPin5, HIGH); // LED rouge ON
delay (500);
break;
case 1: // ufo mode 01
Serial.println("01");
digitalWrite(ledPin3, HIGH); // LED vert ON
delay (400);
digitalWrite(ledPin2, HIGH); // LED bleu ON
digitalWrite(ledPin4, HIGH); // LED orange ON
delay (400);
digitalWrite(ledPin1, HIGH); // LED blanc ON
digitalWrite(ledPin5, HIGH); // LED rouge ON
delay (400);
digitalWrite(ledPin3, LOW); // LED vert OFF
delay (400);
digitalWrite(ledPin2, LOW); // LED bleu OFF
digitalWrite(ledPin4, LOW); // LED orange OFF
delay (400);
digitalWrite(ledPin1, LOW); // LED blanc OFF
digitalWrite(ledPin5, LOW); // LED rouge OFF
delay (400);
break;