In this circuit the TSOP4830 is used as a sensitive infrared detector that does not require shielding from room lighting. The detector will work under almost any lighting condition from complete darkness to full sunlight.
http://home.cogeco.ca/~rpaisley4/IrProximity.html
This range meter uses the ultrasonic of about 40 KHz. About 10-m distance can be measured by adjusting the resistance value.
http://www.hobby-elec.org/e_srm.htm
Ultrasonic Range Meter with PIC16F873.
http://www.hobby-elec.org/e_pic6_6.htm
This range meter uses the ultrasonic of about 40 kHz and uses PIC microcontroller.
http://www.hobby-elec.org/e_psrm.htm