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 fine, but when I put it in a ".py" file, and try to run it, nothing happens. Though the serial lights on my UART do flash. So something is getting through, but it's garbage (I checked).
Here is the simple code.
import serial
ser = serial.Serial('COM3',9600,timeout=.2)
ser.write('A')
ser.close()
I've already tried adding sleeps, but nothing seems to be fixing it. Any ideas?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…