This is Tom Bonar from MaxBotix. If you’re looking to filter the readings of the sensor please read the pre-written response below on filtering.
-Filtering
The filtering that works best, is either a Mode filter or a Median filter. (Did I forget to say, "Do not average the readings"?)
-The Median Filter
The median filter would take the last group of readings and first sort them and then pull out the center reading. Here one might take three or more readings (up to say about 11 for people sensing) and after sorting the readings in order of range, pull out and use only the middle (median) reading. Fairly good filtering.
You can view an Arduino code example by clicking the link
http://www.arduino.cc/cgi-bin/yabb2/...1288290319/3#3.
-The Mode Filter
The mode filter would take the largest group of the same readings out of a set of even larger readings. Very robust filtering.
-Filtering for most applications, the Very Simple Mode Filter
The simplest mode filter, is simple as this question, "Do the last two readings agree?" (with in a certain distance, and the certain distance depends upon how much variation one expects in the actual use. Even so most use the logic of "are these readings exactly the same")? If so, use the readings, otherwise throw away to oldest reading, and compare the next reading with the most current reading and do this again. Obviously with very noisy data, one might have to sample a larger group of readings, and pull out the most common reading, but for most applications, this simple two reading filter works very well.