RIP
AlexanderBunt I now get some usable values, but the last 1cm is not working fine (value stays a bit the same or is even going lower). I think it's because of the wrong resistors, but I don't know…
Everything that others say is right, but let me add that you might be experiencing a characteristic of the sensor for which your only solution might be switching to a different one. The data sheet that @CyberGene posted show the "flattening" at the last 0.5mm from the sensor, but in real life testing (which I haven't posted yet, but I will post it eventually here) I have experienced it happening at much longer distance. @JayKominek has experiencing it too at around 5mm, as shown at https://pianoclack.com/forum/d/289-scanning-speed-and-velocity-mapping-of-cybrid/116 -- so if your "10mm" is eyeballing the distance while moving one hand and looking the screen, what you are seeing is consistent with what everybody else is seening.
This is a unavoidable characteristics of the design of these sensors, due to the parallax of the LED and phototransistor being separate by a distance. The CNY70 have that separation large, so it's more affected than the QRE1113 and EAITRCA6 which have the distance much smaller. But even these are affected by the same problem, just at much closer distances. See here for the raw data on the 'CA6 sensor (and python script to analyze it) and/or https://pianoclack.com/forum/d/289-scanning-speed-and-velocity-mapping-of-cybrid/122 for a plot and discussion: as you can see most peaks do have a "hole". It's not the hammer bouncing back-and-forth, it's the sensor reducing its output at very close distances. We have to design the software and/or the mechanics (e.g. a stop to prevent hammers going too close to the sensors) to live with it.
If you look in @JayKominek github repo you'll find these mechanical "stops" which I plan to use (scaled down in dimensions) for the smaller sensors I will use. @JayKominek since we are discussion this, I actually have concerns that the "holes" in your things will be too big for the size of the hammers and that it will eventually cause too much wear on the hammer sides. Moreover it looks to me that it'd make alignment more critical. Have you thought about all these issues? BTW, should we make a separate thread for this subject?