jasit:
A simple way is create a variable , take your first distance reading, store it, take 2nd reading if lower than the variable replace the variable and so on. You may want to store the servo location also, so that you point to the closest object
What function would I use to do that?