In preparation for PiWars, I wanted to try out using ultrasonic distance sensors to avoid obstacles and find a free path. I rigged up three sensors on the front of my test robot. Then I wrote some code to read the three distance sensors, making the robot move forward if there was sufficient room. When encountering an obstacle, it uses the left and right sensors to judge which is the best way to turn.
Here’s a video of it in action: