Just thought I would post a link to a old video I made of my rover that uses three front mounted ping / ultrasonic sensors to avoid obstacles. One centred and straight ahead. The other two at 45 degree angles. It also has rear sensors to avoid backup collisions.
The innate ability to run parallel to walls seems to be an inadvertent feature of the code adjusting the distance from the 45 degree front sensor to a fixed distance from the wall. It simply keeps adjusting the course until the distance reaches the set threshold.
I know a lot of people ask about code for using a single panning ultrasonic sensor, and in my opinion multiple sensors are superior so that you don't have a delay in finding the obstacles or planning a course that avoids them.
This is using the New ping library. My latest version of the rover uses 6 ping sensors, same setup at the front, but also at the rear.