There are quite a few ways of obstacle avoidance. Here's a couple with the limited time I have.
- Bumper/Touch Sensor
Uses 1s and 0s to measure. If it runs into something, it goes 1 and tries to move around it.
- IR Rangefinder measuring distances from objects
Takes ranges from different points, and when it gets within a defined value from an object, it rotates or performs some line in code.
- Ultra Sonics
Send pulses of sound foreward and recieves it a time later. The time measure is calibrated and a value is given as distance. Again, if it gets within a distance of something, it performs something.
- Camera
An actual camera observes the environment keeping note of things around it. I would recommend only for experts. I haven't even used it yet.
There's a couple ideas, there are more... I just don't have much time. It's all a matter of how much time you want to spend and how much $$ you have on you.
Stupid Capitalism
The codes for all of those are easily found (Except perhaps camera) online. If you choose one, we can probably help get you started.