How to write integers to port using PySerial
First of all, writing 123 12 123 123 123
is not a valid Python syntax.
Create a list or a tuple with your integers: values = (1,2,3,4,5)
Now, we need to convert that data into a binary string that represents our values.
So here how we do it
import struct
values = (1,2,3,4,5)
string = b''
for i in values:
string += struct.pack('!B',i)
# Now send the string to the serial port
Depending on how many bytes you want to use per number, you need to pack them differently. See the documentation here: https://docs.python.org/3/library/struct.html