I've hacked apart an old joystick, and have connected the 2 variable resistors inside to my Uno. The resistors are both 120K, but upon reading their values in the serial window, they change much more when I push the joystick forward than when I push it back. I assume this would be because the resistors are not linear. If they are logarithmic, does anyone know how I can map the values from a logarithmic resistor to a linear output?
I'm assuming you've connected the center wiper terminal of each joystick to an analog input? Is there a way you can verify with a DMM whether this wiper resistance is or is not logarithmic.
You can always pass the raw analog value through an inverse-logarithmic function (the exp() or pow() functions would be a place to start) though this will require computation with real numbers and is considered "time consuming" relative to other things the microcontroller does.
-- The Rugged Motor Driver: two H-bridges, more power than an L298, fully protected
Yea, I've connected to the central terminal. To get the inverse logarithmic function, I would have to first find the normal logarithmic function, by taking samples from the resistor and plotting them? Is there any other way that isn't so much work?
Is there any other way that isn't so much work?