i've been struggling with this for some time now and i'm fairly confused.. any pointers would be very helpfull
jim, instead to take one sample at the time, from your sonar, take several samples and average them, to have a more reliable reading and as conseguence a more reliable behavior of your robot.

Al.