So I did the first proof of concept by simply using photoshop to print a linear gradient on a sheet of paper and holding this paper between an IR-diode and an IR-phototransistor. The result was this:

The horizontal axis is the length in cm. The vertical axis is the measured voltage (transparency of the paper). At 0 cm the paper was completely black and at about 30 cm (length of an A4 sheet) it was completely white. As you can see the area of the first 10cm is relatively linear, so this test was promising.

In the next step I cut of the area between 10 and 30 and enlarged the other therefore. The result is this:

The blue line shows the measurement, the red line the desired and the purple one the difference. The formula above shows the regression curve that excel has calculated.

With this information I calculated the inverse function of the regression curve and wrote an openFrameworks-program that would print a non-linear gradient so that the measurement gets linear. The result is shown here: CODE

This is the final curve. Now both axis are measured in %. As you can see the curve is relatively linear but still pretty noisy but I have to say that I used an ordinary multimeter to measure it. Maybe the curve would look better if I had something to measure it more accurately.

I have started to design a sensor case and uploaded the early version to thingiverse.

But sadly the code is still not capable of creating round gradients, only straight ones so I´m not able to try it at the moment.