From bdb9cdd86dcd2cfe988fa7395b86cf15dd9b68f6 Mon Sep 17 00:00:00 2001 From: "chataigner.g" <> Date: Wed, 12 Oct 2022 11:57:30 +0200 Subject: [PATCH] ralentit obstacle --- main.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 297d63f..c4d3f59 100644 --- a/main.py +++ b/main.py @@ -117,4 +117,29 @@ def lectension(): lecture = ldr.read() tension = (lecture*3.3)/4095 pyb.delay(100) - return tension \ No newline at end of file + return tension + +#15 speed min +def allSpeed(speed): + h1.forward(speed) + h2.forward(speed) + +def vitesse(): + if dist_obstacle() < 5: + speed = 0 + elif dist_obstacle() < 15: + speed = 15 + elif dist_obstacle() < 25: + speed = 20 + elif dist_obstacle() < 40: + speed = 35 + else: + speed = 50 + + if 50 > x+5: + speed = 0 + + return speed + +while True: + allSpeed(vitesse()) \ No newline at end of file