How-To: Scavenge a mouse for parts

ps2 mouse opened
Chris Kiick posted about swarm robotics earlier in the week and today publishes his first Hack-A-Day How-To.

Old computer mice are being abandoned in droves. They’re tossed out because of dirt, obsolescence, or for being entirely too beige. Anyone who has a computer usually has more than one mouse and you can get them for pennies, if not free just for asking. Fortunately for the discriminating (read: cheap) hacker, these little widgets are chock-full of project parts. Today’s How-To will dissect a computer mouse, extract the useful parts, and give some ideas about how to use them.

plan ps2 mouse ps2 mouse underside
Here we have a standard PS2 mouse; a USB mouse will look pretty much the same. We’ll talk about optical mice later on.

Lets open it up. First, take out the mouse ball. Then there will be one or more screws on the bottom side that need to come out. Screws are sometimes hidden under the rubber pads.

ps2 mouse opened
The first thing to notice is the cable connector. Most mice have a very convenient plug for the cable, instead of soldering it onto the board. That’s the first usable part: a 4 (or 6) conductor cable with a nice plug on one end. The socket can be removed from the PCB and used in other projects.


With the cord out of the way, we can start pulling out parts. First thing that pops off is the mouse wheel. Yes, it’s just a big rubber wheel. If you’re annoyed by the mouse wheel’s clicking noise, you can silence it. There are at least two micro-switches and usually a third one under the mouse wheel which can be used for bump sensors or buttons.

encoder wheels
Next thing to take out are the two plastic slotted discs. They’re the encoder wheels. They turn whenever the mouse moves and interrupt an IR beam, producing pulses. It used to be that precision encoder wheels were pretty expensive, but not anymore. Every single (non-optical) mouse comes with a pair built in.

On either side of the encoder wheel are some little boxes. One side is an IR emitter, and the other side is a pair of IR detectors. Sometimes the emitters and detectors will be one complete unit. A pair of detectors is used because with 2 detectors slightly offset, it generates quadrature encoding, so that mouse knows the direction of rotation.

These IR emitters and detectors are fairly modular pieces when it comes to hacking and can be removed with some careful desoldering. It is a good idea to use a multimeter to see what kind of voltage is going to them before removing them. They are probably TTL parts, because mice are powered by 5v, but sometimes they are an even lower voltage. The emitter/detector pair by itself can be interfaced directly. Those parts alone can be used for a proximity sensor or for a line following robot.

Add an encoder wheel and this sensor setup has lots of uses. From a tachometer, to a wind speed indicator, to sensing a robot’s speed, this will do it. The quadrature output (with some decoding) can be used to measure distance, direction, and speed.

IR pair on PCBencoder with PCB and shell
One tricky thing about using the encoder with the IR sensor is getting the emitter to line up with the detector(s). No problem: instead of desoldering the parts from the PCB, use a rotary tool to cut off the little piece of PCB that has the sensors on it (already lined up). Wires can then be soldered to the pins/traces on the other side. If holding the encoder wheel in place is a problem, a hunk of the mouse casing can be used with it. Be sure to leave enough PCB to keep it stable on the mouse casing.

encoder in a robot
This is a picture of an encoder wheel with quadrature from a PS2 mouse on a small robot. Rather than make custom parts, the mouse is carved up and the whole assembly is fitted to the motor axis.

parts salvage from mouse
What’s left to salvage on the mouse? The sensors for the mouse wheel. Depending on the model, the mouse wheel movement may be sensed with switches or a low resolution encoder, suitable for measuring slow rotation.

The final bit is the mouse controller chip. At first thought it seems pretty useless: it’s a single purpose part made specifically to run a computer mouse and nothing else. However, if your controller chip isn’t an anonymous blob, the datasheet could be very enlightening. Octopart can help find datasheets based on the chip’s part number. This (PDF) is a typical datasheet for a mouse controller.

This specific part does a number of useful things:

  • decodes the quadrature input from the encoders
  • keeps a running count of the number of encoder pulses in a set of registers
  • filters out jitter
  • debounces the micro-switches and keeps track of their state
  • packetizes the information and sends it up the cord.

For a PS2 mouse, getting at these features is not too difficult. The PS2 protocol is pretty friendly, even for microcontrollers. Here’s an example of interfacing a microcontroller with a mouse. For USB mice, check the controller’s datasheet to see if it can do both PS2 and USB; with older mice there’s a decent chance it does. While pure USB is not very easy to talk to with a microcontroller, it’s really easy to hook to a PC (with the right software).

optical mouse - no wheels
We promised a look at optical mice. Optical mice do not have any rotary encoders. There are still some switches and a low-res encoder for the mouse wheel. What an optical mouse has in it is a mini-camera, lights, and lenses. The light is probably a fairly standard LED, although they tend to be bright, and the lenses are purpose built. However, it is possible to interface directly to the mini-camera or use it as a really poor scanner.

We hope this How-To has sparked some ideas and that your obsolete mouse won’t seem as useless anymore.

Comments

  1. Skyler Orlando says:

    Salvage the mouse case. Remove the buttons, add a couple collision sensors to the openings, put some wheels in the back and a servo-controlled drive wheel in the front(or vice-versa). Add a tail and sic it on the cat. ;)

  2. tantris says:

    There is this intro physics experiment where a little cart gets accelerated through a dropping weight to show constant acceleration (F=m x a). A simple way to digitize the measurements is to open a mouse, connect a thin thread to the cart and run the thread once around the axis of the encoder wheel. As the cart moves away from the mouse, it spins the encoder wheel. And you don’t even have to unsolder anything.

  3. BigD145 says:

    I’ve taken the LED out of an optical mouse and plopped it right into a MagLite. It was bright red and works well for reading charts at night when you still need to preserve your night vision.

  4. redirector says:

    I just got a free mouse from my teacher at school! She was throwing a ps2 mouse away, and i intercepted…. yay! thanks for the post

  5. Kenneth says:

    The thing I have always meant to do is to build my own two person game controller with the mouse. IE break out the two encoders, then set it up with a game of pong, with x and y axis tied to each player. Use left/right click to restart/pause. It’s a simple hack, but something good to start with.

  6. WestfW says:

    See also my instructable on taking apart an optical mouse, though I didn’t do such a good job at suggesting new uses for the old parts!
    http://www.instructables.com/id/Take-apart-an-optical-mouse/

  7. Those old mice do have a lot of uses. Good topic to do a How-to on.

    I always like this for measuring coil guns http://www.sci-spot.com/Mechanical/ballistic.htm

    And this one as a scale dyno. http://www.sci-spot.com/Mechanical/dyno.htm

    Congrats on the How-To I think you did a good job.
    Jason Rollette

  8. Mac Cody says:

    Though my projects have been posted on Hack A Day previously, I wanted to mention them again because the URLs have changed. One project describes a take-apart and hack of a BTC optical mouse. The other project describes the construction of an robotic optical motion sensor using the parts taken from a BTC mouse, including the Avago ADNS-2610 optical mouse sensor.

  9. Mac Cody says:

    (Let’s try this again with explicit URLs)
    Though my projects have been posted on Hack A Day previously, I wanted to mention them again because the URLs have changed. One project describes a take-apart and hack of a BTC optical mouse (http://home.roadrunner.com/~maccody/robotics/mouse_hack/mouse_hack.html). The other project describes the construction of an robotic optical motion sensor using the parts taken from a BTC mouse, including the Avago ADNS-2610 optical mouse sensor (http://home.roadrunner.com/~maccody/robotics/croms-1/croms-1.html).

  10. :bows:
    luv u hack a day.
    finaly something more along my limited level.
    do like.
    :digs out box of mouses:
    i gots sum work to do
    :walks off humming:

  11. Janne says:

    Old ps2 mouse are great. Here is a project I did last summer converting a mouse to a weather station.

    http://nslu2windsensor.sfe.se/

    Cheers!
    Janne

  12. Morten says:

    Can the mouse wheel sensors be used as a inductor for a ignition system on a car maybe?
    Sound very possible, and super cheap, just fit the sensors inside the distibuter, and fit a custom made wheel, with 4 blades, that triggers the sensor, and sends of a signal to the coil?
    If anyone how if this is possible, send me a mail.
    mo¤rrtenkj@gmai£l.com – Remove the ¤ and £

  13. zawen32 says:

    cool stuff. first, if you can interface a ps2 mouse with a microcontroller, i wouldnt worry about usb. there are these small usb2ps2 adapters(they usually include one with usb mice)if you dont have one, just ask at your nearest IT-Dept. having worked in one, i have dozens, and they usually end up unused in a drawer somewhere..

    also, when i first saw the sprite-mods scanner a few months ago, i immediately wondered: cheapo fingerprint-sensor?? unfortunately im not good enough with electronics yet to pull it off(and all mice i opened used sensors other than the one he used), but if anybody gives it a shot, let me know, it would be a pretty useful hack i think..

  14. Mycroftxxx says:

    @ 12/ zawen32

    You could theoretically use the imager from an optical mouse as a cheapo fingerprint scanner, but these things usually have a resolution on the order of 8×8 or 16×16 (some go as high as 64×64 I hear). No matter what the resolution of the unit, you’re going to only be able to get good data out of it by using some sort of optics to take a _very_ thin slice of the finger and spread the light over the whole surface of the camera. (Think of those fingerprint scanners where you pass your finger over a strip rather than press it against a plate) Those optics will probably be expensive, and I am pretty sure that real fingerprint scanners would be cheaper if you go low-end.

    @ everyone:

    I keep seeing these parts as incredibly useful in CNC and 3D printer building. If you want to know where your plotter/drill/whatever is, these rotary encoders can’t be beat for the price.

  15. rak0ribz says:

    I built a robot for a control systems class a couple of years ago. It used a 68hc12 eval board to talk to an el cheapo laser mouse affixed to a sawed-off wiper blade suspension. You can get X and Y information straight out of the mouse, and I used that as control loop input in a (really simple) control system to keep the robot tracking its commanded path. Cheap mice are overwhelmed by any kind of decent ground speed, though, so it was a bit slow. I never got a chance to try it with one of the more expensive gaming mice that claims fast update rate, but it might work better.

  16. An old project of mine entailed using optical mice to relate axis data back to my 3D software. It was to be used in conjunction with a miniature film rig for tracking purposes in post. Too many cool ideas, not enough parts or money to finish them.

  17. mail toolbar says:

    Great information, Nice to read and useful as I just broke my mouse… Will try to repair it now.

  18. Pedman says:

    Question from someone learning to hack. Once I get the emitter/detector pair out of the mouse, how do I set up my wire leads to get my square wave to read into a scope or in my case LabView data acquisition? IOW’s can someone show me the wiring diagram? Do I need other IC’s from the mouse to make this work?
    Thanks

  19. T. Northup says:

    Do you know a source (or sources) for bying quantity mouse parts like the micro switches, scroll wheel and its holder, laser light, photo sensors, etc?

    • Joe1 says:

      Just get some of the cheap mice from China. I’m sure it’ll break soon enough and you’ll have a part donor. Just joking but you can get the easily as a complete mouse from eBay or your local thrift store. Yeah, old post but maybe another can use it.

  20. fingerprint says:

    Excellent article. I got some pretty useful links from it :)
    Thanks!

  21. Doug says:

    I would like to figure out how to hack a usb mouse so that it produces small mouse movements all by itself to defeat a corporate computer’s screen saver. Any ideas?

  22. ckiick says:

    doug – go low-tech. Use a pager motor to “jiggle” the mouse ball.

  23. tume says:

    Hello.
    I want to make mouse use atmel microcontroller.
    If any one known please help me?
    Is this like as microcontroller serial connumication?
    please help me?
    How can i write code?

  24. Sajid says:

    Can you please give a pin out of the IR receiver of the mouse. And is it open collector type?

    Thanks

  25. Luc_Besson says:

    digital etch-a-sketch here i come.

  26. them0dster says:

    ok i have a question… i am converting an nintendo controller to an opticalmouse and i was wondering if the mouse will work without that plastic piece?

  27. pkt says:

    I’m pretty sure the little plastic piece is used to focus the beam into the right area.

  28. csmith says:

    If you want to build this sensor from scratch (buying the components themselves vs. hacking a mouse), check out this page:

    http://pwc.theclarkwebsite.com/adns2610.php

  29. sissy says:

    u suck men!!

  30. Pratik Saptarshi says:

    Thank you. This post has been both enlightening and informative… In fact, I just planned to go and buy myself some crap useless (for others !) mice from scrap !

  31. no name says:

    hi all…i’m doing a project on optical muse sensor…is anyone know hot to create matlab coding for the resolution of the mouse sensor??thnx

  32. gabe says:

    lazy bastards :) i just opened a mouse exactly like the optical ones you opened (microsoft should quit OS market and focus on mice and keyboards), and guess what? inside the scroll wheel… a IR emitter and detector pair :) and better, attached to the board with reusable connectors! no soldering required.

    also, an encoding wheel sits inside the rubberized scrolling wheel.

  33. Tony says:

    Nice How-To! I like to save the scroll wheels and mouse shells to make toy space cars.
    As for the mouse balls, I save those for typical table-top entertainment such as “Bowling” and “Pinball”, and also for letting the cat chase the ball around on the floor. Thanks! ^__^

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 96,386 other followers