This is my first successful attempt at sending a number (higher than 255) from Python to Arduino using Serial Communication. Currently it sends 3 bytes per execution.
The 1st byte for packet identification, and the 2nd and 3rd byte makes up the Base10 number we are sending. I've used bit-wise operators to maximize the number I can construct from 2 bytes. Currently the maximum number I can send is 65535. The code can still be optimized, and currently it does not support negative numbers but hey, I'm taking it one step at a time (pardon the pun). FYI, this exercise is part of a much larger project. You can read about it Here
Edit: After several requests I have put a revised version of the code to make this work online.
Copy and Paste the Arduino Code into a text file and save as a .pde and upload it via the Arduino IDE. Copy and Paste the Python Code into a text file and save as motor.py
To run it in python, type:
import motor [Enter] motor.position(1,1.8,360) [Enter] motor.position(1,1.8,0) [Enter]
This should make a 200 steps per rev motor turn 360degrees and then return to it's original position. The only thing that you may need to change is line 20 in the python code. It depends on what COM port you will be using.