Pyserial problem with Arduino - works with the Python shell but not in a program

后端 未结 4 425
悲哀的现实
悲哀的现实 2020-12-17 21:03

All right, so I am positive my Arduino circuit is correct and the code for it. I know this because when I use the serial monitor built into the Arduino IDE and send \'H\' an

4条回答
  •  青春惊慌失措
    2020-12-17 21:50

    Just to make it a bit more clear I'll modify the code so everyone can see what needs to be added!

    import serial
    import time
    ser = serial.Serial("COM4",9600)
    time.sleep(3)
    ser.write("H")
    

    Adding in a sleep statment helps to let the serial open up without any problems!

提交回复
热议问题