Mouse Brains Plus Line Laser Equals Rangefinder

[Neumi] wrote in with a sweet robotics hack. It’s a 2D laser distance sensor (YouTube) made with a cheap line laser and an optical mouse’s flow-sensor chip used as a low-resolution camera. In one sense, it’s a standard laser-distance-sensor project. But it is clever for a whole bunch of reasons.


For one, using a mouse sensor as a low-res camera is awesome. It’s designed to read from a standard red LED, so the sensitivity is in just the right ballpark for use with a line laser. It returns a 30×30 pixel greyscale image, which is just about the right amount of data for a low-end microcontroller to handle and keep up with the framerate without resorting to coding tricks.

It’s also no coincidence that these sensors are available with lenses built in, for relatively cheap, on eBay. Apparently the quadcopter gurus use them as if they were mice to visually track their quad’s motion. Hacker spillover!

Detecting the laser line as it reflects off of whatever objects are lying on [Neumi]’s floor could also possibly prove difficult, and might produce false readings in the presence of background illumination. So [Neumi] takes two readings with the camera — one with the laser on and one with it off — and differences them. Done fast enough, this should reduce any non-laser sources down to the sensor’s noise floor. Finally, there’s some thresholding and averaging going on behind the scenes that help make everything work out right. The code is up on GitHub.

Not a bad build for a 2D laser distance system on a budget. If you want to shell out a bit more money, and are into a seriously involved build, this is probably the slickest we’ve seen in a long time. And if you’re thinking that you’ve heard of [Neumi] before, you’re right: we featured this 405mm laser PCB exposer / burner CNC machine just a few months ago.

14 thoughts on “Mouse Brains Plus Line Laser Equals Rangefinder

    1. Haha, I assumed they were REAL mouse brain cells. I thought of a thing a while back where some scientists manage to train some mouse neurons to maintain level in a flight simulator.

  1. Useless fact: back in the stone age when this type of optical mouse first came out (like, a quarter century ago), the DOS interrupt 33h actually supported dumping the sensor data. Over the serial port. At 9600 baud. You could (slowly) move the mouse over a page and, using 2-D correlation, piece together the itty bitty images to build a large image. It made a crappy page scanner, but it worked.

  2. In my experience, the best hack related to optical mouse sensors would be *actually finding a place that sells them*. DigiKey, Mouser, et al, are forever out of stock. It seems like the only way to get a hold of one is to either cannibalize a working mouse, or to be a big enough company that you can call up the manufacturer and commit to buying several thousand of the sensors.

    1. Yeah. I needed a handful of these optical sensors before and it was easier + cheaper to just rip apart a bunch of crap optical mice for them. You also get the necessary lens piece as well which seems to be even harder to buy than the sensor module itself.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.