Optical mouse sensor and the Arduino

Arduino Technology
Optical mouse sensor and the Arduino

This is a great way to interface an optical mouse with your Arduino. Just make sure your mouse has one of the required optical sensors before you do any permanent damage. If you are interested in a How-To Tuesday based on this project, let me know in the comments. Thanks!

More about connecting an Optical mouse to an Arduino

In the Maker Shed:
Arduino Family
Make: Arduino

20 thoughts on “Optical mouse sensor and the Arduino

  1. Todd says:

    I would love to vote YES! for a Tuesday How-To.

    1. Marc de Vinck says:

      OK, it’s added to the list.

      1. sburlappp says:

        How fast can the image sensor bitmap be read out? You might be able to make a barcode scanner out of one of these. (I’d like a mouse with that built in!)

        How fast movement can these things track? You could make a tire-mounted bicycle speedometer/odometer. (Nearer the hub might be easier to keep up with.)

        Or, you could improve the repeatable positioning accuracy of a maze-solving robot (and greatly speed up its second run).

        Or, by mounting the sensor in the right place, and adding an Arduino and some relays, you could turn almost any electrically powered wheel/pulley/piston into a reasonably accurate continuous servo or linear actuator – for example, three bumper winches could be used to make a nice large-scale X-Y(-Z) positioning system. (I’m thinking: Parking Lot Plotter!)

        1. vivi says:

          The internal DSP has access to 1500fps image data (or more on newer models). Unfortunately to access this data externally you’re forced to use the serial port, which is very slow. 15fps might be the max you can get this way.

          Your idea to use it as an odometer is quite good. My G9 gamer mouse has a max speed of only 3.8m/s (about 14km/h) though, so a cheap standard mouse has probably an even slower limit.

          1. sburlappp says:

            That’s why I’m thinking very near the hub would work better, maybe put something with a visible texture in the spokes, and read it from 1/4 of the wheel radius, to measure 1/4 of the tire surface speed.

            You could build a nice surveyor’s wheel (hodometer) this way, too. (At walking speeds, you could measure directly off the tire, or the ground!)

  2. Simon says:

    You can also get the actual image off those mouse sensors too. I did it once using the parallel port on the PC and a little C# application. Unfortunately I lost all that code after a hard drive crash :(

    1. vivi says:

      I made a similar hack using an Arduino and some Java code : http://www.bidouille.org/hack/mousecam/index.php

      1. Marc de Vinck says:

        That’s awesome!! Thanks for sharing. I’m going to post about this tomorrow. Keep an eye on the blog.

  3. eliasyria says:

    hello there.
    i am trying to use the optical mouse that i have to measure the speed of surface. I do not have Arduino, i have connected the mouse to a USb ANALYZER and collected data that shows me the changes of X and Y’s. it seems that i need to write a C program for that and i do not have enough skills, can any one help me please

    1. Mihai says:

      if you managed to do that… i would be very thankful if you could help me do the same…

Comments are closed.

Discuss this article with the rest of the community on our Discord server!


Maker Faire Bay Area 2023 - Mare Island, CA

Escape to an island of imagination + innovation as Maker Faire Bay Area returns for its 15th iteration!

Buy Tickets today! SAVE 15% and lock-in your preferred date(s).