Base roulante code
This commit is contained in:
@@ -5,7 +5,31 @@ def main():
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
while True:
|
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
|
# Lancer automatiquement si ce fichier est main.py
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Reference in New Issue
Block a user