pySerial works fine in Python interpreter, but not standalone

后端 未结 4 1876
我在风中等你
我在风中等你 2020-12-15 23:06

Good morning! Recently I bought an Arduino board to make sort of \"light control\" in my room. Here is the code of the firmware I wrote:

int control = 0;
int         


        
4条回答
  •  抹茶落季
    2020-12-15 23:57

    I think it's probably a race condition between when the serial port is opened and when the data are sent. I'd probably stick a sleep in between the open and the write calls.

    Alternatively, instead of using this library "serial" you might want to just open and write directly to the device, perhaps it's doing something funny (see the double open mentioned in other posts)

提交回复
热议问题