-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrobotSerialTester.py
More file actions
37 lines (28 loc) · 1.05 KB
/
robotSerialTester.py
File metadata and controls
37 lines (28 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# import serial
# ser = serial.Serial('/dev/ttyACM0', 115200, timeout = 1)
# while True:
# if ser.is_open:
# try:
# # Create a string of four comma-separated integers
# data_to_send = "42, 12, 8, 56\n" # Make sure to include the newline character
# # Send the string to the serial port
# ser.write(data_to_send.encode())
# print("Data sent:", data_to_send.strip())
# # Wait for a response (optional)
# response = ser.readline().decode().strip()
# responseList = response.strip().split(',')
# integer_list = [int(element) for element in responseList]
# print(integer_list)
# except:
# pass
#!/usr/bin/env python3
import serial
import time
if __name__ == '__main__':
ser = serial.Serial('/dev/ttyACM0', 9600, timeout=1)
ser.reset_input_buffer()
while True:
ser.write(b"Hello from Raspberry Pi!\n")
line = ser.readline().decode('utf-8').rstrip()
print(line)
time.sleep(1)