4
\$\begingroup\$

I want to read data from a mouse with the help of Arduino. I want to calculate relative motion between two objects. My questions are

1) Is it possible?

2) How is mouse interfaced with Arduino?

\$\endgroup\$

closed as too broad by Olin Lathrop, Daniel Grillo, Keelan, placeholder, Matt Young Nov 20 '14 at 21:24

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    \$\begingroup\$ Are you asking about a USB mouse, a PS/2 mouse or a serial mouse? \$\endgroup\$ – John Honniball Nov 20 '14 at 14:30
  • 2
    \$\begingroup\$ If you can get hold of a PS/2 mouse or a serial mouse it would be much easier. \$\endgroup\$ – pjc50 Nov 20 '14 at 14:50
  • \$\begingroup\$ The mouse interface used by the Amiga looks like it is as simple as a mouse interface could possibly become. But an Amiga mouse may not be that easy to come by, so using PS/2 may be a better idea for that reason. \$\endgroup\$ – kasperd Nov 20 '14 at 17:14
5
\$\begingroup\$

For a USB mouse, the data transfer is very complicated. First of all the host (computer) must discover the presence of the mouse (it may have been hot-plugged). Then, the host must find a device driver, and in the case of a mouse, this will be a HID (Human Interface Device) generic driver. Finally, the host will open USB endpoints and actually transfer mouse motion data in the form of X,Y co-ordinates and button up/down bits.

This is something that's hard to do with an Arduino. You'd need to get a USB host interface shield, and then write a sketch (program) to drive it. If you really want to interface a mouse with an Arduino, you may find it easier to get a PS/2 mouse (an obsolete PC-compatible standard) or a serial mouse (another obsolete standard, seen on all types of computers), or a quadrature mouse (very raw interface going directly to button switches and motion sensors).

\$\endgroup\$
  • \$\begingroup\$ While obsolete, devices with old PS/2 and serial interfaces are still manufactured and it is possible to buy them. There are a lot of old systems out there in various industries (e.g. medical, retail) that do not get upgraded for a variety of reasons (cost, if it ain't broke don't fix it) and they need replacement parts. \$\endgroup\$ – user52164 Nov 20 '14 at 18:45
4
\$\begingroup\$

1). Is it possible?

Yes, of course. If your Arduino has a USB interface (more accurately USB device interface or OTG), it'll be easier.

2). The former PS/2 mouse and the modern USB mouse, or Bluetooth wireless mouse (also use USB interface). The former two are easier to implement on MCU.

The PS/2 is easy to implement, but it's a bit outdated. So, may you want to try USB. Then you need known USB protocol, particularly HID class protocol.


Update:

As you choose to use PS/2, then you can go here: http://www.computer-engineering.org/ps2protocol/, it's really easy, you can implement it using only two pins, a clock and a data pin.

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.