This post is about building a Simple IR Proximity Sensor based on PIC16F877a micro controller. Usually these simple circuits are built using discrete components and include an OP AMP for comparing the photo diode voltage to a preset value. Current implementation uses only a few parts. Instead of operational amplifier Analog to Digital Converter of PIC16F877 was used to convert a photo-diode voltage to a digital form and compare it with a threshold settings defined by sensorThreshold constant. See attach assembly source code at the bottom of the page. Few words about operation of the sensor. The IR LED constantly transmits a beam of IR light towards an obstacle. As soon as a non-transparent surface is present it will reflect the light to the photo diode causing it to generate a voltage proportional to the intensity of the reflected light. While working OK indoors you should be aware that a direct sunlight on the photo diode can lead to a false reading. Here is the schematic of this design.