serate output from sensor

I'm fighting with a sensor that gives unstable or serate measurements on a square-wave input (optical sensor either hit or not hit by emitter). Can anyone point me to info on this kind of 'nerverous' sensor-output .. or how to make a simple low pass filter?

Perhaps this could be useful as a low pass filter. GitHub - sebnil/FIR-filter-Arduino-Library: FIR filter Arduino Library
I used it in one of my projects.

hi sebnil,
I've saved the link.
From a quick look at the FIR.cpp I may get a problem on setting the filter in that the output-frequency is not constant.
I worked on another sensor-output yesterday, one that's less serate, but none the less poses the same problem. It's an isolated project, so I can opt to use brute force: I use both an interrupt on rising and falling edge and uses 'debounsing' on the three 'events' that can be extracted. That's a lot of resources on output from a mechanical switch that is flipped by the dents of a wheel.
.. I admire your flawless syntax ..