Python Output as Arduino Input

Hey, I am very new to Arduino in general. I’m planning on controlling a stepper motor using Arduino Mega 2560. I used accelstepper library and watched a tutorial on youtube, through which I could provide “direction, speed, angle” as inputs in the terminal and the motor would rotate as desired.
Now, I have a python code that outputs “direction, speed, angle”. I want the Arduino to take those outputs as inputs and rotate the motor as desired. How do I go about doing that?

Just make sure that the Python output is in the same format as the Arduino code expects it, and that Python code outputs to the Arduino’s serial input.

This Simple Python - Arduino demo should give you some ideas.

The Python code should work on Windows if you edit it to use the Windows style of COM ports.

Also have a look at the examples in Serial Input Basics - simple reliable non-blocking ways to receive data. There is also a parse example to illustrate how to extract numbers from the received text.

...R

Robin2:
This Simple Python - Arduino demo should give you some ideas.

The Python code should work on Windows if you edit it to use the Windows style of COM ports.

Also have a look at the examples in Serial Input Basics - simple reliable non-blocking ways to receive data. There is also a parse example to illustrate how to extract numbers from the received text.

...R

Great! I was able to use PySerial to communicate with the Arduino. Thanks.