how to Measure distance with photo transistor and led

This setup can be used if the transmitter and receiver are a few millimeters apart and the closest to furthest distance is also only a few millimeters. It will take hand calibration to record the distance versus the ADC reading.

Even model railroad scale would be "large" for this setup.