From the Forums: USB Control for Autofocus Microscope Camera
Check out this excellent project from Adafruit forums user kazzle101.
He posted the code up on GitHub as well!
Here’s a solution to an everyday problem that I know effects literally dozens of people throughout the world.
The camera on my microscope has a fairly poor autofocus function, it has a tendency to wobble around focus hunting, so I would normally operate it in manual mode and refocus when needed using the USB mouse control. I found the mouse control to be a bit clumsy, and got in the way when I was working on various electronics.