Coversion of PS2 mouse to filament counter

3D printer filament counter (length measure) using a mechanical PS2 computer mouse and Arduino.

Similar projects worth following
Ever wonder how much filament did you actually use for a project? Have an old mechanical ball mouse laying around waiting for recycling? Let's convert it into a filament counter with simple Arduino and 3D printed parts.

The mechanical PS/2 mouse contains fairly high resolution encoder wheels and a simple serial interface as well as electronics to process the quadrature input signals from the encoder wheels. There are Arduino libraries written to talk to the mouse and get the direction of the distance of rotation of the encoder wheels. By connecting the encoder wheel to a filament roller, we can track the actual usage of the filament for each project by using the Arduino and display the results in millimeter on a LCD display. Since the mouse outputs the relative position to its original position in both positive and negative directions, the counter is able to accurately measure and actual usage of the filament even when the filament direction is reversed occasionally.

See it in action:

The display has two rows. "U" is the current filament usage in millimeters. "T" is the total filament usage from the beginning. There is one RESET button. A short click will reset the "U" counter to zero, which is useful for each new project. A double click will reset the "T" to zero which s useful when replace the filament rolls. Additionally, when the unit powered up, the user is able to choose the direction of the filament movement, i.e. forward or backward depending on the mounting position of the sensor unit by pressing the Reset button.


Pinout for the PS/2 socket

JPEG Image - 27.80 kB - 12/07/2016 at 01:21


  • 1 × PS/2 Mouse Dell Logitech 2-Button PS/2 Ball Mouse M-SAW34
  • 1 × Arduino UNO Or other Arduino boards
  • 1 × Serial LCD 1602 16x2 Module With IIC/I2C Adapter Blue or green
  • 1 × 12x12x7.3mm Momentary Tactile Push Button Switch with key cap
  • 1 × 625zz bearing 5x16x5 Shielded Miniature Ball Bearing

  • FilamentBot is born

    Bin Sun02/15/2017 at 07:12 0 comments

    The details of the Amazon DRS enabled FilamentBot project is aviaiable at

  • Dual Extruder

    Bin Sun12/09/2016 at 05:46 0 comments

    The mouse has two channels, i.e. X and Y. So far only X is used, but it can be easily extended with an additional channel, handy for those have dual-extrudes. Just print and assemble anther sensor body and make a small circuit board to transplant the IR emitter and receiver to the 2nd sensor body. The software is capable of reading the Y axis already, just need to add some extra lines of code and maybe the Reset to make it work.

  • Connected Device

    Bin Sun12/09/2016 at 05:41 0 comments

    How about turn it into a IoT device? With IFTTT it will notify you the filament jam (timing out) or breakage (with an extra micro switch), or even order the filament for you when it runs low!

  • Basic functions and future development

    Bin Sun12/06/2016 at 21:54 0 comments

    Now it has basic functions, will add a filament out micro switch to enable the M600 in Marlin. Also considered is the implementation of jamming/print finished sensor if the wheel stops for extended time. Also the device can send automatic email/SMS notifications to notify the owner when filament out or jamming dectected.

View all 4 project logs

View all instructions

Enjoy this project?



Shailesh Joshi wrote 04/04/2019 at 16:15 point


it seems that the VCC and GND Pins in the jpg file are wrong and should be swapped.

  Are you sure? yes | no

Michael McGrew wrote 01/20/2017 at 23:21 point

I built one.  Works as intended.  One thing I notice is that the total filament used amount resets when the arduino is powered off.  Also, I notice a slow refresh of the LCD display which is distracting.  It is almost perfect except for these "issues".   Would there be any way to store the total used amount so it's not lost between prints?  Is there any way to speed up the LCD refresh rate?  I'm willing to beta test new code if you decide to work on these issues.

  Are you sure? yes | no

Bin Sun wrote 02/15/2017 at 07:10 point

Hi Michael

it is possible to store the number in the EEPROM so it won't get lost when powered off. I'll see how to make it happen. The flickering of the screen is due to 'high' refresh rate and the slowness of UNO. 

Thanks for your support!

  Are you sure? yes | no

Bin Sun wrote 12/13/2016 at 15:45 point

Great ideas. Since the mouse MCU is taking care most of the processing, I imagine it's doable to implement your ideas in current firmware such as Marlin. Thanks!

  Are you sure? yes | no

TTN wrote 12/08/2016 at 20:13 point

Now all you need is to be able to use this with one of the reprap lcd panels, then have a menu, be able to scroll up and down, see filament used, weight, how much that weight costs, then have a setting to be able to set the filament density, and cost per meter (or kg).

  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