[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

Valutazione Template - Joomla! Forum - community, help and support

SD Datastring Convention

First use of Arduino Uno : avrdude error on Blink uploading