For translating mechanical motion into digital information, you'll need an encoder. Peruse Clearwater's line of absolute, incremental and linear encoders to find the right one.