Skip to content

Commit

Permalink
serial script
Browse files Browse the repository at this point in the history
  • Loading branch information
mxhng committed Apr 9, 2024
1 parent c6e9456 commit 7209035
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions electrical_code/serialSend.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import serial
import time
import sys

arduino = serial.Serial(port='COM5', baudrate=115200, timeout=.1)
def write_read(x):
arduino.write(bytes(x, 'utf-8'))
time.sleep(0.05)
#data = arduino.readline()
#return data

def move(angle, dist):
dist, angle = str(dist), str(angle)
angle = '0' * (3 - len(angle)) + angle
dist = '0' * (3 - len(dist)) + dist
command = angle + dist
write_read(command)
#print(command)

while True:
move(100, 431)
'''
while True:
command = sys.stdin.readline() # Taking input from user
comm1 = write_read(command)
print(command) # printing the value
'''

0 comments on commit 7209035

Please sign in to comment.