PySerial App runs in shell, by not py script

后端 未结 6 664
你的背包
你的背包 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:10

    import serial
    import time 
    
    ser = serial.Serial('/dev/ttyACM1', 9600, timeout=1)
    time.sleep(3)      # this will needed for initializing arduino
    serial.write(b'1') # b is necessary for byte
    

提交回复
热议问题