Skip to content
Snippets Groups Projects
Commit b2f8a624 authored by Ilona Szczot's avatar Ilona Szczot
Browse files

Added new python script to test forces

parent dd54834b
No related branches found
No related tags found
No related merge requests found
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment