← Back to ratslair.com
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdvin <[email protected]>2025-05-15 10:42:55 +0200
committerEdvin <[email protected]>2025-05-15 10:42:55 +0200
commit28f7162043ed6f36c913695b9ef1b92324be7a7c (patch)
tree893a89e98f1416c9ff579490c75d8d349c23b77a
parent359580d25472eabebbad18bdbb1d77b70c23b227 (diff)
Changed angle polarity for backwards adjustment and added reverse/forward on obstruction
-rwxr-xr-xmain.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/main.py b/main.py
index 0968f67..02fb728 100755
--- a/main.py
+++ b/main.py
@@ -44,13 +44,13 @@ def adjustAngle(adiff, f, b):
elif b == True:
print("Going backward")
if adiff < 0:
- adiff -= 180
+ adiff += 180
print(f"Adjusting to the right {adiff}")
NANO.write(b"Right\n")
sleep(abs(adiff) / 90)
NANO.write(b"Stop\n")
elif adiff > 0:
- adiff += 180
+ adiff -= 180
print(f"Adjusting to the left {adiff}")
NANO.write(b"Left\n")
sleep(abs(adiff) / 90)
@@ -304,11 +304,17 @@ if bto.find("Connected") != -1:
forward = False
if backward == False:
NANO.write(b"Stop\n")
+ NANO.write(b"Backward\n")
+ sleep(0.5)
+ NANO.write(b"Stop\n")
if ((a > 155 and a < 165) or (a > 195 and a < 205)) and (d > 0 and d < 150):
backward = False
if forward == False:
NANO.write(b"Stop\n")
+ NANO.write(b"Forward\n")
+ sleep(0.5)
+ NANO.write(b"Stop\n")
if forward:
NANO.write(b"Forward\n")