简体   繁体   中英

Optical mouse and x-y coordinates

How do I get the xy coordinates for an optical mouse?

I'm getting some readings while interfacing the mouse to a PC via an Arduino , but it can't find a way to relate it to xy coordinates corresponding to the mouse position.

From the web:

The best solution is to find a PS/2 only mouse and interface that.

A USB mouse can be interfaced to Arduino using a USB Host Shield, but this is more expensive than the mouse (and the Arduino,). so you would need good reason to use it.

Because the mouse works low speed USB, there is software for the AVR which does a bit banged low speed USB. This however is significant load on processor and software architecture. It would not sit so well with other Arduino libraries if you want a general purpose solution.

It appears you need to do more research on the operation of the PS/2 mouse. It does not provide xy position data, but relative motion data, relative to the last reported motion data.

I have found two postings on GitHub with library files for interfacing a PS/2 mouse to an Arduino:

PS2Mouse

arduino-ps2-mouse

Rucek provided two links to excellent articles on the operation of the PS/2 mouse:

http://computer-engineering.org/ps2mouse

http://www.computer-engineering.org/ps2protocol

These have been extremely helpful to me in understanding and implementing a PS/2 mouse on the Arduino.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM