Mouse-controlled Microscope

Arduino + geared stepper motor control of microscope XY stage and focus. Inspired by need for an amputee to do veterinary lab work.

Similar projects worth following
A relatively inexpensive lab-grade microscope is converted to be operated using a mouse.

Using a microscope sourced on eBay, designed custom 3D-printed motor mounts and gears to control the XY stage and focus. With the exception of using longer screws to replace existing microscope screws so that the motor mounts can be secured, and gluing on some magnets for home positioning the XY stage, there are no modifications needed for the microscope.

An Arduino MEGA is used with a prototyping shield to manage sensor, mouse input, and motor driver control. The control system is mounted in a custom 3D-printed box with external illuminated rotary encoder and push button to manage settings and modes.

A separate 3D-printed housing holds 3 stepper motor controllers; one each for X and Y movement, and one for focus. Geared steppers are used to ensure fine control.

gear_generatorKSK 3.scad

Modified from design by Leemon Baird, 2011,,

scad - 16.19 kB - 11/03/2019 at 23:29


scad - 3.24 kB - 11/03/2019 at 23:26



Updated previous version to include hall sensor mounts and license. Mechanical stage motor mount for OMAX Microscope 40x-2500x. This body style However, may be able to modify for other bodies.

scad - 5.00 kB - 07/08/2017 at 18:24



A model of the 28BYJ_48 geared stepper motor. Useful for creating mounts and making sure that your mount matches the motor. For example, I import this model and have an option to display it "in place" or slightly offset from the mount I am designing...

scad - 3.65 kB - 07/08/2017 at 17:32



A simple block mount for the 28BYJ_48 motor.

scad - 1.59 kB - 07/08/2017 at 17:31


View all 8 files

View all 13 components

  • Arduino Camp Demo

    ksk07/26/2017 at 14:31 0 comments

    I finished the main functionality for the scope last week and took to the University of Alberta Engineering DiscoverE camp for a demo. It was the main, end demo for a little talk I gave a grade 7-9 "Awesome Arduino" campers on the idea of "software-enabled everything". 

    It was a lot of fun to be there and answer some very good, and sometimes hard questions. They all got to play with the scope. I'll get to present to campers in the second round Aug 10th.

    All that remains is to update the Fritzing file, fix a bad encoder button red LED wire, and tweak and update the arduino source. Then, of course, post it all.

    Then on to the next project!

  • Hardware Done

    ksk07/19/2017 at 01:38 0 comments

    The hardware is finished.

    Three new photos are uploaded to the gallery and 2 were deleted as they no longer represent the current state. The new photos focus on the stepper mechanicals. To mount the focus motor I had to drill and tap the back of the scope, which was a little nerve-wracking as I was not sure how much metal there was. I did take things apart completely and could measure the cast thickness near my drill locations, but could not measure them as I did not have deep enough calipers.

    I also have made the Arduino control case larger because the original case, based on a RAMPS case, was cramped when it came to wiring. Instead of my hacked together protoshield, I bought a proper shield from Digikey and rewired everything, taking the opportunity to add a reset button and "centre" button. The latter will move the XY stage to centre the slide under the optics; seems like a nice thing to have.

    The XY homing algorithm works nicely and I have X motion working with the mouse. Y will be the same, just different motor address. Focus will be the easiest because I don't have to worry about endstops or coordinates. The focus will control the "fine" adjustment knob since that's what you will use most one coarse focus has been set by hand.

    The wiring between the scope and control boxes is still kind of ugly, but it does work.

    Tomorrow I will finish code and test so that it's ready to be demo'd on Thursday to 16 campers at the U of Alberta DiscoverE "Amazing Arduino" summer camp. Should be fun.

  • openSCAD update

    ksk07/09/2017 at 03:46 0 comments

    I realized that the uploaded model for the XY motor mount was not what I thought; it was missing the Hall Effect sensor mounts that are clearly shown in the photos. Not sure why and I could not find a source file that had them, so I suspect I made mods in openSCAD and then did not save them. Silly!

    I've also included the 28BYJ_48 geared stepper motor and mount source files (openSCAD) that are referenced by the XY motor mount.

    The case for the Arduino Mega controller was too small, so I made changes to make it taller. That provides more space inside for wiring. It also seemed a good idea to add a reset button and a second button that I can use for mode selection or something -- I've not yet decided as I need to review the existing code.

    The next, and final step is to design a mount for the third 28BYJ_48 that moves the fine focus of the scope. Two more gears are needed, so back to my custom openSCAD gear generator, which will likely result in an update to that source. The code to control fine focus should not be too hard; I will use left and right mouse buttons for closer (down) and father (up).

    This all will have to be done in the next 11 days as I need the unit to show to Grade 7-9 students at a summer engineering camp with a focus on Arduino programming. Quite looking forward to it!

  • Push to completion...

    ksk06/08/2017 at 21:55 0 comments

    I will finally have time to complete this project and publish all the code and remaining artefacts (e.g., focus motor control mechanical design files). The push comes from the need to have it done before mid-July so I can use it as part of some university summer camp sessions. Volunteered to help with beginning Arduino programming for grades 7-9 and very much looking forward to it.

    It is only the focus control that needs to be completed and it should be easy enough to build on the existing design and code base.

  • Delays...

    ksk03/02/2017 at 21:22 0 comments

    This not really an update, but more of a whiny excuse blarg.

    Paying work and home renovations keep getting in the way of completing this project. Plus revamping my MendelMax 2 printer means that I haven't yet printed the final motor mount and gears for the focus function.

    While I wait for the final paper work on a continuation of a customer project from last year (SDR stuff), I hope to find time to finish the the microscope project and write it all up.

    It will get done!

  • Catching up on previous docs

    ksk10/31/2016 at 04:59 0 comments

    Uploaded a schematic, some openSCAD files for motor mounts and controller housings, and a component list.

    Still to do:

    • Design motor mount for focus control
    • Add in code for focus control
    • Review modes and see if I can't add a "centre slide" function/mode
    • Tune mouse control of XY motion

    One probably concern is how to keep the lens from crashing into a slide. Ideally you'd need a way to know which lens has been selected (2 hall switches and 3 magnets?) and then a calibrated focus height... too tired to think of that now.

  • Progress to date...

    ksk08/24/2016 at 16:12 0 comments

    I will be adding source files, links, and other details over the next few weeks. Everything is or will be open-sourced.

    The motor mounts and gears that are matched to the manual control wheels on the microscope are all specific to the microscope I bought. I suspect that there are many models from the same company that can use the designs as is, but it's likely you will have to modify the designs for your own. That means getting out a rule and other measuring tools to determine mount points, etc.

    As of this initial post, what is working includes:

    • XY stage motors mounted
      • Gears made and mounted on steppers and matching microscope XY spindles
    • Arduino-based mouse input and motor control
    • Hall sensor XY automatic homing
    • Illuminated push-button rotary encoder and second push button mounted and interfaced to Arduino
      • Encoder push button used to enter parameter setting mode
        • Set fast and slow speeds for motors
      • Other push button used to change mode; fast and slow XY, fast and slow focus

    May try to add a "slide center" mode.

    Moving on to testing mouse XY control integration ("unit" tests complete), then starting on focus mechanical.

View all 7 project logs

Enjoy this project?



Bernard Peek wrote 04/24/2020 at 09:25 point

I'm most interested in microphotography. At first glance this looks interesting.  Automated XY stepping should work well with stitching software to create big images. Z stepping should make automated focus-stacking possible and that could drastically improve image quality.

  Are you sure? yes | no

ksk wrote 02/05/2020 at 19:44 point


The gear measurements were all rather empirical. I agree that I should have done better documentation on the design. Basically,  I first designed the motor mount with the assumption that putting it on the stage itself was the only way to go. The main objective was to space the motor shafts to align with the concentric XY control shafts. Then I measured the centre-to-centre distance between the motor shafts and the control shafts (obviously, with the motor shafts aligned vertically, this was only one measurement). 

Then, I measured the XY control shaft diameters, and started to iterate the design in the gear generator until everything lined up. You can imagine that not all gear radii would result in feasible combinations of motor and control shaft gears. I think I kept the gear tooth depth constant across iterations.

My rationale was that since I didn't really know how fast things were going to be and I had no absolute requirement, I wouldn't worry about it. Only after I had gear designs that worked (meshed :-) would I see if the speed was okay. As it turns out, it's pretty decent for what I want to do.

For the z-axis, I chose only the fine focus control and just designed two gears that would further slow down the fine control speed. The focus motor mount is attached to the column support via two machine screws. Once I had the gears designed, I made the mount with elongated holes, position it, marked the holes on the microscope column, then drilled and tapped them. Of course, I had already had a look inside to make sure that I wouldn't drill into anything that matters.

The focus speed also turned out quite well. Those little gearhead motors will spin pretty fast for this scale of project and are pretty accurate and precise. It's a pain to have to zero them every time I turn it on, but it only takes minute or so.

Not sure what else to say other than thanks very much for the interest!

  Are you sure? yes | no

Ahron Wayne wrote 02/05/2020 at 19:17 point

Hey, if you're still on hackaday --- have you considered trying to use this for automated xy/z scanning? I have a project like that with a USB microscope, would be eager to see results with good optics. 

  Are you sure? yes | no

ksk wrote 02/05/2020 at 19:46 point

Another person has used this project as the starting point for an automated scanning system, I think looking for soil bacteria. They are still developing it, but it will remain private as it's for a startup company. 

I don't really have a need for full automation, so am unlikely to take this further.

  Are you sure? yes | no

Ahron Wayne wrote 02/10/2020 at 21:29 point

Hey, well thanks for your response. All the best with your current endeavors

  Are you sure? yes | no

Travis Hale wrote 04/18/2018 at 09:11 point

Looks fantastic, i have a Radical RXL-4T microscope which is a very similar style to the one you did your work on and I am keen to automate it in a slightly different way (software control). 

I am wondering if you could share the gear measurements you used for the X and Y axis microscope stage (e.g. not the motor side), as the Files include the gear generator but i am not entirely clear on how to create the gears for the X and Y axis (to be coupled to the microscope), also could not see how the Z axis is attached to the microscope in the model?

Z axis is less critical to me, as i have managed a direct couple using a NEMA17 stepper motor, although it would be much easier to use the smaller stepper motors. Out of interest how was the speed of the Z axis using the small stepper motors (since i thought they were geared fairly slow) and you are controlling the fine focus?

Thanks for a great project!

  Are you sure? yes | no

ksk wrote 02/05/2020 at 19:47 point

I thought your question was of general interest, so just posted the response directly to the feed. Thanks!

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates