How do I properly use Sharp GP2Y0A21YK0F sensor?
These sensors really put a lot of noise on the line. I'm using here a similar sensor (the GP2D120XJ00F). First, add another 100nF ceramic cap parallel to the existing 10µF cap. This helps to better damp the changes in current consumption of this sensor. Additionally, I added a low-pass filter to the output (10k resistor and 100nF capacitor), to smooth the output signal. (I then use an averaging filter in the MCU when reading the input, but then I don't have the need for really fast reaction times).