from logique_BR import * def main(): print("Démarrage") sleep(1) try: while True: distance = mesure_distance_cm() if distance is not None: print(f"Distance: {distance} cm") if distance < 20: print("Obstacle détecté !") moteurs_stop() sleep_ms(200) reculer(VITESSE_BASE) sleep_ms(500) moteurs_stop() sleep_ms(200) tourner_gauche(VITESSE_BASE) sleep_ms(600) else: avancer(VITESSE_BASE) else: print("Erreur capteur") moteurs_stop() sleep_ms(100) except KeyboardInterrupt: print("Arrêt du programme") moteurs_stop() # Lancer automatiquement si ce fichier est main.py if __name__ == "__main__": main()