How can I send real time xy mouse coordinates from a desktop to an arduino?

I am working on a project that will move a couple stepper motors depending on where the cursor is on the screen. I'm sure there are many ways to do this, any thoughts? I'm thinking serial communication?

The communication problem is way down the line. Do you want the screen coordinates of the xy position of the cursor or do you want the step signals from the mouse handler code? When you decide which you want, then you have to be able to get those values as well as let the PC programs continue to use the functions as they are.

Paul

Use python. You can get the mouse coordinates using pyautogui and send them to the correct serial port at the selected baud rate.

1 Like

Looking for xy position of the cursor, i want to be able to jiggle my mouse on the desktop for example and see the xy position change real time

Thanks ! I'll look into this

That XY position is relative to the current window the program is running in.
Paul

Are you saying different programs can have different xy positions for the same cursor position?

Are you saying different programs can have different xy positions for the same cursor position?

Read this page:
Automate the Boring Stuff with Python

Start by getting it to display in python the way you want. Then we can work on the serial stuff.

Sounds good thank you sir

You can also reverse this and use an Arduino as a joystick mouse.

I'm not really sure what I'm doing. I just downloaded python from the internet, now trying to use python to download pyautogui?

Have you installed python yet?

If yes:
In "type here to search" type cmd
In the results you will see a command prompt icom
Right-click on that icon and select run as admin
Click ok/yes on the security window
Type pip install pyautogui and press enter
If you get an error we will need to add python to your PATH

I think I'm making progress

Yup. now you are ready to wrangle that python.
In the same search box type idle
The in the file menu select new file and take a screenshot.

'idle' is not recognized as an internal or external command,
operable program or batch file.

Do I need to set as a variable?

Where did you download python from?

I can't remember now, I'm using command prompt not python. Does that matter?

Close python, close the command prompt.
In 'type here to search' type idle