A mouse with malfunctioning buttons can be a frustrating to deal with — and usually a short leap to percussive maintenance. Standard fixes may not always last due to inferior build quality of the components, or when the microswitch won’t close at all. But, for mice that double/triple-click, will release when dragging, or mis-click on release, this Arduino-based hack may be the good medicine you’re after.
Instructables user [themoreyouknow]’s method cancels click malfunctions by latching the mouse’s controller switch trace to ‘on’ when pressed, keeping it there until the button normally closed contact closes again completely. Due to the confined spaces, you’ll want to use the smallest Arduino you can find, some insulating tape to prevent any shorts, and care to prevent damaging the wires this process adds to the mouse when you cram it all back together.
Before you take [themoreyouknow]’s guide as dogma, the are a few caveats to this hack; they are quick to point out that this won’t work on mice that share two pins between three buttons — without doing it the extra hard way, and that this might be trickier on gaming or other high-end mice, so attempt at your own peril.
Speaking of gaming mice, we recently featured a way to add some extra functionality to your mouse — cheating optional — as well as how to stash a PC inside an old Logitech model.
I had a very high end mouse’s left click just give out literally 2 months out of warrantee … Luckily an old mouse used a switch of the same dimensions so the replace was simple … But gives a different click sound that messes with my OCD some times
If I got bouncing problems like this, first I’d hit it with contact cleaner, even if you can’t get the switch open, hold down the button and spray
Chances are it has hardware debouncing … A hardware swap of the components can help
If it does not put in your own or even just a cap across the switch
If that fails, this might be for you if the cost of the mouse is too much, its rather ingenious and does not lower mouse click responsiveness by much that you would get with heavy debouncing
I’d personally buy a new mouse, but this looks like it could be very useful for enabling users with motor disabilities such as parkinsons or other issues to use a mouse easier. Really interesting hack.
That was my first thought – just buy a new one…
But that said, some mice (gaming specific) can be pricey, and this hack could be applied to old mice (eg: 1980s & 1990’s era) that had gone faulty. Using an Arduino for such a task is a bit much though! I’d go with a SOT23-5 and some hookup wire.
An attiny even in the dip8 is really small and a rail of them is cheap and better than an arduino if you are already trhough-holing, the programmer board to make it arduino or at least digispark for you is about a US$ too. So these projects become super easy to make super small, even smaller if you are using the SM attinys which are perfect for Kapton boarding and stuffing inside your project.
pcb design is a bit beyond me, and i just tinker as a hobby, I wouldn’t bother if the difficulty was too much. While I did get a digispark running at one time I tend to use the serial console a fair bit for debugging which is missing on them. rather than study the attiny i’d like to learn more about the stm32 however the learning curve on linux is a bit steep for its toolset.
Basically that seems equivalent to the RS-Flip-Flop for contact debouncing. In this case, where one line of the switch is to be considered as input and output to the Flip-Flop, a simple latch made out of two cross coupled transistors (*) could do the trick. And it has some big advantages:
1.) It does not need any software
2.) It is cheap – at least a genuine arduino is more expensive than most mice. Two transistors and two resistors cost around 2,2ct.
*) Assuming, that the mouse button connects to ground when pressed and the “root” or “COM” contact of the switch is connected to GND:
Take two small NPN transistors (e.g. BC847), couple each base to the collector of the other and give them pull-ups of 10k from the collectors to VCC, one pull-up resistor can already be in the mouse from the original circuit, then make the new one of the same value. Now connect the NC and NO contact of the switch to the collectors of the transistor.
If one base is pulled to GND, the corresponding transistor switches off and switches on the other one. If the contact bounces, the state stays stable until the NC contact of the switch closes.
If the COM of the microswitch is connected to VCC use the inverted structure with PNP transistors.
I actually did build a circuit using mostly discrete components soldered on stripboard in the link. It was just about small enough to fit inside the case and debounce one switch but I wanted to do them all. Since I didn’t know how to use kicad to miniaturize a smt pcb I had to use an arduino.
The circuit I built was based on the cd4001 which is positive switched but every mouse is negative switched, that is why i changed the circuit to the cd4071. I doubt a dual flipflop to debounce two switches would be much smaller than a quad srlatch to do the same job, then add in transistors or optoisolators to pull each switch trace to ground.
The advantage of the arduino is that it can run in parallel with the switch whereas the flipflop cannot as the switch must be disconnected from the mouse to wire in the circuit in series, i think.
I have never seen a mouse that uses common to vcc but while it would be workable, the problem is to rewire the switch contacts in cases where common is switched. I tried this on a few cheap mice and destroyed them.
That’s one advantage of the 2-transistor solution – the button does not have to be disconnected.
And it’s minimalistic in it’s parts count. You don’t need a PCB, just a bit of superglue to stick the 4 components in TO-92 package and standard THT resistor package together, clip the leads and connect them. Then wire that into the mouse. Probably 3 units also fit, although I have never seen another mouse button fail than the left one. You could also solder this with 4 SMD components (SOT-23 and 0805) if you want.
Never had the problem, but wheel slip bugs my Microsoft mouse. It goes back a step in some spot.
In my experience MS mice always get cable issues at the base of the housing, then it becomes time to cut a bit of bad cord off and reattach the rest.
The error can be very elusive though, it can be click issues or scroll issues or intermittent ‘a device has malfunctioned’ message while you never actually lose mouse functionality, making you nuts looking fro what device is malfunctioning.
Wow a complete microprocessor as a flip-flop. Crazy that mice builders don’t use the NC contact anyway.
Mouse button switches are surprisingly unevenly implemented; I’m not sure why.
On the one side, you have (typically specific models or revisions) of comparatively fancy and expensive mice that are absolutely notorious for switches going intermittent or failing shortly after warranty is up (I got bitten myself not long ago; the thing went from working perfectly to, perhaps every 5-10 presses, either registering nothing or registering a single press as a rapid double-click).
On the other side; you have the probably-cost-under-$5 pack-in mice that manage to survive years of brutal service(eg. heavily used school computer labs). Back when some of those were my problem; we had plenty of hardware destroyed by users; but strikingly low rates of more subtle failure: either some kid had actually torn the buttons off/destroyed the USB/PS/2 connector; or the thing just kept working; and these were just the basic junk included out of the box with low end business desktops from Dell, HP, etc.
I’d really be interested to know where in the chain the issue creeps in. I’m assuming that, even if they aren’t technically on the hook for warranty replacement, Logitech or the like doesn’t [i]want[/i] the customer displeasure of having their switches go wonky after a fairly short time; and the fact that total cheapskate mice can (sometimes) survive 5+ years of constant, careless, use suggests that the problem is solvable with cheapo components; but in practice quality seems to be rather variable. Some switch vendors better than others? Some bafflingly bad designs around those switches?
The optical sensor part of things, by contrast, never ceases to amaze me: so much less horrible than ball mice; and even the absurdly cheap ones Just Work(unless you give them a really cruel surface, like mirror finish glass; which only the classy sensors can really cope with); despite the fact that ‘just point a very high frame rate camera at the surface and DSP your way into inferring the movement between frames’ sounds more like Rube Goldberg science fiction than a commercially viable plan. And yet, it is a commercially viable plan(and I think even cheaper than doing it with a ball and optoencoders at this point; since that technique seems to have completely vanished in even the cheapest devices).
I suppose it’s just another example of how, if it can be done in silicon, it has enjoyed amazing gains over the past few decades, while if it has to be done mechanically, it is much more mature but has less low-hanging-fruit left to take advantage of.
key switches are usually rated in operational cycles before failure. so its very easy to pick a switch that will fail at a specific time the a very high certainty. this time is usually a month out from the warranty period. because its better for buisness to make people buy a new mouse every 2 years.
logitech takes this to a new level. my ancient mx5000 laser mouse still works and has been repaired at least a dozen times. mind you logitech makes this very difficult. the mouse has a 2 pcbs sandwiched together with some headers, the pads for the keyswitches are not accessible at all. then on top of that uses some solder with an absurdly high melting point. so the thing is very difficult to separate without breaking it. my epic soldering skills were up to the task, replaced that lead free crap with proper vintage rosin core lead solder. now i can take that sandwich apart every time it needs a keyswitch. i still had to break the charge terminals to fix it, but some epoxy and jumper wires fixed that issue. logitech is very unfriendly to diy repair.
its also had other failure modes, like the battery pack. it started to fail so i replaced it with an old cell battery. still works great. then its rubberized plasic started to degrade making the mouse rather sticky. i just removed it with rubbing alcohol (be careful to use a solvent that wont dissolve the plastic) making it rather ugly but still quire functional.
and thats ignoring the fact that the bottom layer was screwed to the case before the top layer was soldered on, another damn gotcha that i forgot about. its ok, i drilled out the holes from the bottom and was able to remove all the boards from the case. in retrospect i should have desoldered the pcb first, but at the time i wasnt very confident with how well the repair would take and figured i had nothing to loose. a little epoxy filled the hole just fine. number of logitech products bought since: 0.
Wonder why they don’t just use micro reed switch?
That’s actually a fun idea!
Keep the microswitch for tactile feedback and wire a reed-contact to act as the real switch. then glue a small magnet to the button. But maybe the travel is too short for a reed switch to be practical…
Optical switch, keep the click switch feedback, maybe some leveraged shutter?
Feedback from a motor/solenoid is unnecessary complication and at least on phones and always feels like those 1/100s/s especially to spin up a motor really decouple from the input.
They now make mechanical keyboards with optical switches.
a4tech bloody make mice with optical switches. I hear they break down for other reasons though. Still someday i’d like to gut one for parts to play with.
A reed switch would have the same bounce problems a microswitch has. Then there’s this huge switch for 300+ dollars each.
https://www.youtube.com/watch?v=F97RP9EGmW4&t=42s
I don’t know anything about 555 timers.
>There is many software for mouse debounce.
While that’s true, adding a longer bounce period disables the ability of a mouse to double click. It is acceptable for middle and right click for most uses. It’s possible to do without the arduino and sacrifice a spare button to solder a jumper between it and left mouse switch. Then code pc software to latch the left button with a press and unlatch left with the press of the spare button. I have tried it on linux and it does work but it didn’t interest me, partly because i ran across a bug where other buttons become unresponsive.
Surely there must be a way to do it with a 555, right?
Indeed.
http://abdulrahman-225-vp8.weebly.com/timer-blog/555-timer-switch-debouncing-circuit
HAHAHAAAAAA
You beat me to it.
so arduino instead of replacing $1 microswitch? this is just … heh
i usually just swap the key switches. somewhere in my junk collecting i ended up with about a dozen old skool ball mice. which of course being 90s tech still work despite their age and being the standard issue 2-button and scroll variety that usually comes with a new computer. these mice had the same type of keyswitch as my more modern wireless mouse: cheap chinese edition. this left me with about 36 replacement buttons. only problem is my scroll wheel is starting to go tits up, they used a mechanical encoder instead of an optical one for some reason. ive yet to find a good replacement in my junk piles, so contemplating doing some kind of hall latch based encoder to replace it.
also contemplating the build mouse from scratch route. apparently the optical mouse sensor is easy to work with provided you can find a data sheet (the hardest part of the whole endeavor). use one of those blackberry trackballs you can get off ebay for $3 for the scroll wheel, and a bunch of cherry keyswitches for the buttons, run the whole kitten kaboodle with an esp32, using its bluetooth capabilities.
wheel encoders are $1 on ebay straight from china, any size you want
Ok, you can swap the microswitch (which most of us have probably done)… but I think the real point here is the idea of using the NC switch pin to make a latch and improve reliability.
I have found that mice with 9-pin rs232 connectors have very good donor switches. (I know you packrats have not thrown them away yet) You do have to replace both left and right, because the donor switches usually need a noticeably larger click-force.
I used an AutoHotkey script to “fix” my old mouse that was double-clicking randomly instead of single clicking. I used it that way (even while gaming) for about a year until I replaced it. Cheap and lazy alternative that could work in some cases :)
usually use software debouncing for all my arduino button projects. works so well i got my own little library for it. just include debounce dot h and pass your inputs through the class and call a member at a regular interval to update the button states. doesnt even use any hardware resources.
I also use an AutoHotkey script (Buggy-Mouse.ahk) to fix bounce issues with my MS IntelliMouse Explorer 3. Works great!
I just repaired my double-clicking Intellimouse Explorer optical mouse. I had to dismantle the microswitch, bend the little flat spring, then reinsert it. The only difficult part was reinserting the spring. Took me a good 20 minutes to get it hooked into the eensy teensy grooves. But now it works great. I bought some replacement microswitches since I think I’ll probably only get away with the bending process once due to metal fatigue.
My Logitech trackball is maybe 20 years old and recently started double clicking when I wanted only a single click. I designed a debounce circuit with 2 transistors, 2 capacitors, a diode, and a few resistors to give me about a 40 mSec debounce time. Today I built it on a small piece of “vector board” and connected it inside the trackball with 3 short wires. One wire to +5, one to ground and one to the switch wire….It seems to have solved the problem. No need to break any internal wiring. BTW one website measures double click speed and the fastest I could do (using a different but same type of trackball) was about 130 mSec. This means that the 40 mSec speed limit imposed by the debounce ought not be a problem, at least for me. I guess some gamers might be able to go faster than 40 mSec but this circuit timing can be changed with component values. This analog electronic solution might make sense for somebody who has the parts and technician skill, but if you need to buy everything it might make less sense. I would post the schematic diagram if I knew how and where……