I’m trying to connect a Joystick/Encoder/Button (Copal Electronics CJ25) to a Raspberry PI. Using gpiotest I managed to get it up and running pretty well – using 3.3V input (though the data sheet mentions 5V).
The problem is, that each of the joystick’s axes has 3 levels of voltage as output. 0x, 0.5x and 1x input voltage. So with 3.3V input there’s 0V, ~1.7V, 3.3V.
Is there a way to simply step up/down voltage (resistors?), so that by using two different GPIOs I can detect all three states with those digital I/Os ?
You MAY be able to use the Pi logic levels to detect this, but it would be unreliable. (The trigger point is ~1.3V, but varies from Pi to Pi.)
The only thing you can rely on in <0.8V => LOW; >2.0V => HIGH.
An ADC would be overkill, all you need are voltage comparators – these are cheap, and available in multi comparator packages e.g. LM339 or LM393. See https://en.wikipedia.org/wiki/Comparator