From c814255af2afd29dff1ccca2f2fd07341da1cd21 Mon Sep 17 00:00:00 2001 From: Edvin Date: Wed, 7 May 2025 12:28:00 +0200 Subject: Fixed left wheels reversing on shutdown --- arduino/arduino.ino | 19 ++++++++----------- main.py | 6 ++---- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/arduino/arduino.ino b/arduino/arduino.ino index 708fcec..425d82d 100644 --- a/arduino/arduino.ino +++ b/arduino/arduino.ino @@ -1,8 +1,8 @@ #include // To H-bridges -const int D1 = 10; -const int D2 = 11; +const int D1 = 9; +const int D2 = 3; const int D3 = 6; const int D4 = 5; @@ -16,8 +16,6 @@ LiquidCrystal_I2C lcd(0x27, 20, 4); int emptySpace = 0; void setup() { - pinMode(LED_PIN, OUTPUT); - digitalWrite(LED_PIN, HIGH); pinMode(D1, OUTPUT); pinMode(D2, OUTPUT); @@ -84,15 +82,14 @@ void loop() { if (received.indexOf("Closing down") >= 0) { lcd.clear(); - lcd.setCursor(2, 0); - lcd.print("AGV booting!"); + lcd.setCursor(1, 0); + lcd.print("Shutting down!"); received = "Dot dot dot dot"; - Serial.end(); - - delay(5000); - - Serial.begin(9600); + digitalWrite(D1, LOW); + digitalWrite(D2, LOW); + digitalWrite(D3, LOW); + digitalWrite(D4, LOW); } if (received.indexOf("Forward") >= 0) { // Forward diff --git a/main.py b/main.py index f26c89d..fde3ff2 100755 --- a/main.py +++ b/main.py @@ -16,14 +16,14 @@ GPIO.setup(LED, GPIO.OUT) GPIO.output(LED, False) # DWM Process Code -DWMProcess = subprocess.Popen(["/home/pi/venv/bin/python", "-u", "/home/pi/TNE107-RPI/DWM.py"], stdout=subprocess.PIPE, text=True) +DWMProcess = subprocess.Popen(["/home/pi/venv/bin/python", "-u", "/home/pi/TNE107-RPI/DWM.py"], stdout=subprocess.PIPE, stderr=open(os.devnull, 'wb'), text=True) print(f"DWM PID: {DWMProcess.pid}") # Open serial port to Arduino Nano NANO = serial.Serial('/dev/ttyUSB1', 115200, timeout=1) sleep(2) -BluetoothProcess = subprocess.Popen(["python", "-u", "/home/pi/TNE107-RPI/bt.py"], stdout=subprocess.PIPE, text=True) +BluetoothProcess = subprocess.Popen(["python", "-u", "/home/pi/TNE107-RPI/bt.py"], stdout=subprocess.PIPE, stderr=open(os.devnull, 'wb'), text=True) # Waiting on connection NANO.write(b"Bluetooth up\n") @@ -227,5 +227,3 @@ if bto.find("Connected") != -1: print("Terminating Bluetooth Process") os.kill(BluetoothProcess.pid, signal.SIGINT) - -# def calc_turn(desiredDirection, currentDirection): -- cgit v1.2.3