I am attempting to control a stepper motor with python. The commands I am attempting to send are:
MN
LD3
MR1000
5
V10
D30000
G
Here is the code I have:
Did you bother to read the how to get he most from the forum posts?
Those posts will tell you what sort of information that we need in order to help you.
Information that is helpful:
Please post your code. Clean it up by running the IDE autoformat tool before posting in code tags as suggested by the how to get the most threads,
A schematic or wiring diagram is often helpful and are always less ambiguous than a written description. Show all components and power supplies.
After opening the serial port in python, the Arduino resets and the bootloader is invoked. You will have to wait till the bootloader is finished doing what it is doing. Adding a delay of 10 seconds after ser = serial.Serial('COM6',9600) will do. The 10 seconds is chosen because you did not specify the board that you're using.
The better way is to send a message (in setup()) from the Arduino to the PC and your python script should wait till it has received this message after it has opened the serial port.