python 与Arduino沟通以为是串口

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 与Arduino沟通以为是串口相关的知识,希望对你有一定的参考价值。

/*READ*/
import serial
ser = serial.Serial('/dev/tty.usbserial', 9600)
while 1:
  ser.readline()
  '1 Hello world!\r\n'
  '2 Hello world!\r\n'
  '3 Hello world!\r\n'

/*WRITE*/
import serial # if you have not already done so
ser = serial.Serial('/dev/tty.usbserial', 9600)
ser.write('5')

以上是关于python 与Arduino沟通以为是串口的主要内容,如果未能解决你的问题,请参考以下文章