use an optocoupler, the intensity of a led shines on an LDR or photodiode which resistance can be measured. YOu only need to make some hardware that controls the led in a well known way. Preferably linear because that would be easy to map() - for non linear there is multiMap - Arduino Playground - MultiMap -
You can also let the frequency of pulses change and detect that. This can be optical like above or maybe magnetic with a reed switch or a hall sensor.
just thinking out loud ...