I have a 170mm touch sensor that sends 0-5V into Arduino, giving me a range of 0-1023 from the ADC. I have a stack of 64 LEDs next to the sensor, ~170mm tall. I divide the 0-1023 value by 16 to determine which LED to turn on adjacent to the sensor. It sort of works except in the middle of the sensor...
It is more accurate at the ends, e.g. my finger on the bottom of the sensor lights the bottom LED, but as I move up towards the middle of the sensor the LED begins to lag behind. As I approach the top of the sensor it "catches up" and then is accurate again near the top.
So I think I need to add a curve into the calculation to compensate for this non-linear difference between the physical position on the sensor and the value of the LED to light up.
I'm sure there's some handy function to do this but my math isn't so great. Any help appreciated!