int capteurAvant = A0; int capteurGauche = A1; int capteurDroite = A2; int compteurAngle = 0; void avancer() { Serial.println("Avancer"); } void tournerDroite() { Serial.println("Droite"); compteurAngle -= 90; } void tournerGauche() { Serial.println("Gauche"); compteurAngle += 90; } void setup() { Serial.begin(9600); } void loop() { int avant = analogRead(capteurAvant); int gauche = analogRead(capteurGauche); int droite = analogRead(capteurDroite); bool murAvant = avant < 300; bool murGauche = gauche < 300; bool murDroite = droite < 300; // Si pas de mur devant et compteur = 0 → avancer if (!murAvant && compteurAngle == 0) { avancer(); } // Si mur devant → suivre le mur else { if (!murDroite) { tournerDroite(); } else if (!murAvant) { avancer(); } else if (!murGauche) { tournerGauche(); } else { tournerDroite(); tournerDroite(); } } delay(200); }