[solved]Problem writing serial strings - Raspberry Pi Forums


using python 3 want send serial string raspberry pi arduino that's running sinewave generator. works fine

code: select all

ser = serial.serial('/dev/ttyusb0', timeout = 1) ser.write(b'200')
need frequency variable

code: select all

f = '200' # raises error ser.write(f) # sends garbage ser.write(b'f')
doing wrong?

you have encode it, first convert number string. can like
str(f).encode()
python2 did lot of things 'automatically' ok of time frustrating!


raspberrypi



Comments

Popular posts from this blog

Error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode - Raspberry Pi Forums

class MPU6050 has no member named begin

missing filename after '-o'