From b2f8a6246f58d2e7f9552888da654df83bcf3884 Mon Sep 17 00:00:00 2001
From: iszczot_liu <ilona.szczot@liu.se>
Date: Mon, 21 Feb 2022 08:57:02 +0100
Subject: [PATCH] Added new python script to test forces

---
 send2arduino.py | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
 create mode 100644 send2arduino.py

diff --git a/send2arduino.py b/send2arduino.py
new file mode 100644
index 0000000..97e0f20
--- /dev/null
+++ b/send2arduino.py
@@ -0,0 +1,30 @@
+import serial
+import time
+
+
+TEST_VALUE = 1000
+SLEEP_SEC = 5
+
+# com port for arduiono usb
+COM = "COM4"
+# baudrate same as in arduino
+BAUDRATE = 115200
+
+try:
+    my_serial = serial.Serial(COM, baudrate= BAUDRATE, timeout = 2)
+    print("Device found")
+    # translate to something that will be read by arduino
+    arg = bytes(str(int(TEST_VALUE)), 'utf8','ignore') + b'\r'
+    # send value to arduino serial
+    my_serial.write(arg)
+    # hold that value for SLEEP_SEC
+    time.sleep(SLEEP_SEC) 
+    # release by sending negative value
+    arg = bytes(str(int(-TEST_VALUE)), 'utf8','ignore') + b'\r'
+    # send to arduino serial
+    my_serial.write(arg)
+
+except:
+    print("Problem finding device.\nCheck your com port or device.")
+    
+print("All Done")
\ No newline at end of file
-- 
GitLab