How to properly clean up a noisy signal with a capacitor
If you're a software guy, then you can filter the noise in software, that's the cheapest option :)

But considering you do want to make a low-pass filter, you need a capacitor and a resistor.







simulate this circuit &ndash; Schematic created using CircuitLab

You can compute the RC constant as R*C, in the example that would be 100 * 0.000001 (because C is measured in Farads), or in this case 100 µs. Very crudely speaking (google around for more), fast signal changes that are quicker than the RC constant will get attenuated, slower ones will be passed through. You should decide whether those 100 µs are still too quick and increase the resistance (for example), should you require more filtering.