At its heart, the obstacle avoidance program is very similar to the line following program. Rather than using a PID controller to steer towards dark areas, we use it to steer away from them. We had to increase our PID gains quite a bit to make this work, since we wanted to feature large obstacle regions which, if the robot ran over too quickly, would not have enough time to respond and would have no idea which way to turn (since all five IR sensors would be saturated), and would therefore just drive straight.
The speed of the robot can be adjusted up or down by using the A or C push buttons. The B button will make the selection and start the program.
Download Project Tabletop source code (which includes the obstacle avoidance program) here.