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.

35 thoughts on “How-To: Scavenge A Mouse For Parts

  1. 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. 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. 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. 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.

  5. 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.

  6. (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).

  7. 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 £

  8. 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..

  9. @ 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.

  10. 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.

  11. 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.

  12. 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

    1. 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.

  13. 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?

  14. 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?

  15. 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 !

  16. 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.

  17. 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

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

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