Noise reduction
Noise is everywhere. This world is made of noise. This is what everybody related to sensors will constantly repeat. But what is noise? It's unexpected data generated by sensors or signal sources. It can completely ruin the behavior of an autonomous system if not treated properly.
Here, we will use the implementation from the Measuring distance – infrared and ultrasonic recipe. The Sharp IR is known for its interference with basically anything, and here we will explore two standard methods of filtering the data generated by the sensor.
Getting ready
The following are the ingredients needed for this recipe:
An Arduino board connected to a computer via USB
A Sharp infrared proximity sensor such as the GP2Y0A21YK or the GP2Y0A02YK0F
How to do it…
This recipe uses the implementation from the Measuring distance – infrared and ultrasonic recipe. Please implement the same circuit as you did there.
Code
The following code will read the output of the Sharp IR sensor and will use two filtering...