← Back to ratslair.com
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdvin <[email protected]>2025-05-07 13:41:49 +0200
committerEdvin <[email protected]>2025-05-07 13:41:49 +0200
commit9e5aabc05c41365bffeedc20fe50be26cb02bbbb (patch)
treefdd8d3fa0ad673bf867b09f31e3faf8734e131b5
parent0c1cbed626f914b9c5ce85e8d9b29ea0b15e027b (diff)
Improved LIDAR implementations
-rwxr-xr-xmain.py25
1 files changed, 13 insertions, 12 deletions
diff --git a/main.py b/main.py
index f87fcbf..0fe2dc8 100755
--- a/main.py
+++ b/main.py
@@ -200,18 +200,19 @@ if bto.find("Connected") != -1:
sleep(1)
GPIO.output(LED, False)
- iteration += 1
-
- if iteration == 10:
- with open("distances.txt", "r") as f:
- for line in f:
- a, d = line.split()
- a = int(a)
- d = int(d)
-
- if (a < 20 or a > 340) and d < 20:
- print("Something in front")
- forward = False
+ with open("distances.txt", "r") as f:
+ for line in f:
+ a, d = line.split()
+ a = int(a)
+ d = int(d)
+
+ if (a < 20 or a > 340) and d < 300:
+ forward = False
+ if backward == False:
+ NANO.write(b"Stop\n")
+
+ if (a > 160 and a < 200):
+ print(f"{a}, {d}")
if forward:
NANO.write(b"Forward\n")