PySerial App runs in shell, by not py script

后端 未结 6 663
你的背包
你的背包 2020-12-16 07:01

I have a very simple python script that uses pySerial to send data over the serial port to my Arduino. When I execute this line-by-line in the python shell, it works just f

6条回答
  •  無奈伤痛
    2020-12-16 07:19

    OK, I've figured it out!

    It's necessary to use code like this before performing the write:

    time.sleep(1)
    ser.setDTR(level=0)
    time.sleep(1)
    

    Otherwise, the arduino automatically resets upon receiving a serial connection for some reason. yay!

提交回复
热议问题