This question already has an answer here:
I am trying to send commands via serial from Python to Arduino with the code below.
If I save this code in a dedicated python file "Stepper.py" (Python2.7 on Mac OSX) , the code runs successfully but nothing happens (the code does not trigger a motor connected to Arduino).
If I start terminal and run the same code from the interactive shell it works as expected.
How can I run it via a dedicated file ?
import serial import time ser = serial.Serial(port="/dev/cu.usbmodem144231", baudrate=9600, timeout = 0) ser.write("200+") time.sleep(1) print ser.read()