The schematic linked to by 007 is not what is being discussed. That is just an IR photodetector not the 38kHz IR detector.
I would like to post the schematic and code but have never figured out to put an image in here. I sure its simple so maybe some can get me a hint (please PM).
The detector I use, and is functional the same as the one in the link the OP first posted, is the Panasonic PNA4602.http://www.solarbotics.com/products/pna4602/
Schematic is really simple. +5V to IR LED, other end of IR LED connects to three resistors, 1.8k, 1.2k & 390. Each of these resistors then connects to a PIC output pin. When all three PIC outputs are low the LED current is maximum at about 15mA. Change the PIC pin that should not be low to an input reduces the number of resistors in parallel and thus the LED current and brightness. The combinations are:
1.8k || 1.2k || 390 = 252, ~14.3mA
1.8k || 390 = 320, ~11mA
1.8k || 1.2k = 720, ~5mA
Allowing four maximum detection distances.
The PIC code has a timing loop to pulse the active pins with a 38kHz square wave. Once this loop runs for the PNA4602's detection time (600us) the PIC input pin from the PNA4602's output is sampled. The code then loops through the resistor (LED current) combinations and sets the two PIC output pins to the detection distance code.