You need two resistors with the phototransistor as shown in the attached GIF.
The phototransistor is an infrared sensor but you will get the best results if you use one that is designed for the same wavelength as your IR source. Ambient light also contains IR so range is usually rather limited for unmodulated IR as you cannot differentiate between signal and ambient IR. For example, IrDA which uses 850nm unmodulated IR has an effective range of about 1-2 meters.
This link might help you understand the fundamentals of IR.
I would not use the perceived strength of the IR beam to measure distance. There are two many variables that will affect it. The normal method is to send a pulse of ultrasound and measure the time it takes to echo back.
Bookmarks