I know this question has already been asked, but the answer I'm looking for here is different.

I found out about this forum post explaining the best way to smooth out the reading of a IR sharp sensor (it seems really great based on facts and measurements).

The thing is I don't know much in electronics, I'm wondering where should I put the capacitor and resistor described in this post: `10uf ceramic capacitor and 530 ohm resistor parallel to the capacitor`

.

"Where should I put it" means where do I connect it. Thanks

## Best Answer

What you want is a

low-pass filter. A low-pass filter will let slow changes in your signal pass, but block faster changing signals. The basic low-pass filter is thisRC-filter:\$V_{IN}\$ is the signal from the sensor. \$V_C\$ is the capacitor's voltage, which you could use to go to the

ADC(Analog-to-Digital Converter) of a microcontroller, for example.The capacitor acts as a voltage reservoir, which is filled or emptied via the resistor. The higher the capacitor's value the longer this will take. A higher resistor's value will cause less current to flow to and from the capacitor and also will deny fast changes.

Now you may think that the higher the values, the better smoothing you get, and that's true, but if you go too high you'll also prevent the normal changes due to the change in distance from the sensor. And those changes are allowed.

The key to finding the right values is the

cutoff frequency, that is the frequency starting from which the filter will block a signal. For the RC filter:\$f_C = \dfrac{1}{2 \pi \times R C}\$

Say you want to allow changes of 1Hz, that means changes which take place in 1 second. Then according to the formula

\$R C = \dfrac{1}{2 \pi \times f_C} = \dfrac{1}{2 \pi \times 1} = 0.16\$

If you choose a value of 1\$\mu\$F for the capacitor you'll need 160k\$\Omega\$ for the resistor.