how to Measure distance with photo transistor and led

Both the transmitter and receiver are highly directional, so for reproducible results you'll need them always to be pointing in the same direction.

And high levels of ambient light will mess up the results.

I don't think you'll get more than an approximate measurement this way.

Allan