# [RE-SOLVED] Joystick board for Arduino Uno

I bought two cheap Mearm robot arms with included Unos (clones) and joystick boards. The joystick boards act very strangely to me. One board consists of two joysticks:

One joystick has two trimpots with the code 103, so they should be 10 kOhm, right? But when I measure the pins directly on the board, the far most pins of each potentiometer gives some 2.3 kOhm. When I measure the middle pin (the sweeper) and either of the other pins, I get some 3.7 kOhm.
What I'd expect is that the far most pins give 10 kOhm and the middle one would give 5 kOhm when in rest. And the middle one would change linearly when the joystick is twisted. Now the middle one changes from 3.7 kOhm towards zero, when I turn the joystick to one side. But when I turn it to the other side, the value first arises to almost 5 kOhm, then it drops to some 2.3 kOhm at the far edge. What's going on here? Is this intended behaviour or do all 8 pots in the 2 joystick boards happen to have same fault? If it's intended, what is the purpose of it? As it is, when my program gets a reading like 520, I can't tell whether the joystick is in the middle or at the far edge.

Do you have a link for the joystick board? I tried finding a schematic for it but was not able to quickly locate it.

It sounds like other objects in the system are creating a resistance in parallel with your pot. If you removed the pot from the board you would be more likely to get the reading that you are expecting.

However, it is more likely that it is in a voltage divider circuit and it is the ratio of the two resistance values that matters, not the actual resistance. I would suggest instead measuring the voltage on the wiper (middle pin). One of the other pins will probably read 5 volts, the other ground. As you move the joy stick you will see the voltage change. Move your joystick to the position you want to check, measure the voltage. You can then divide that voltage by .004883 and that will be what you should read on the Arduino analog input.

The .004883 value comes from the Arduino VCC supply (5V) divided by 1024 (number of steps of the analog input).

If your joystick is centered you should read a voltage of about 2.5 volts, and that should result in a reading of 512. Perfect pots are rare, so I would expect and error of up to about 30% on the middle of the pots.

Also, re-reading your question, when you are measuring the wiper resistance and it goes up to nearly 5k and then it suddenly drops, that is simply some diode junction somewhere that has reached it’s threshold. I think that if you removed the joystick board from the Arduino and measured again you would be getting readings more like you expect.

But, taking those resistance measurements is probably not the way to go about it. I would measure the voltage on the wiper, or the analog input that you are using.

Are you using more than one analog input? If so, in your code you need some settling time between readings. If you read from A0 first and then go to A1 to take a reading it takes about 200uS for the stray capacitance to fade away.

I do something like this:

delayMicroseconds(200);

you have to take a reading from the second port twice to bleed off the stray voltage from the first port.

You are unlikely to get 512 as a reading when the pot is centered, 520 sounds pretty good. You should be able to get a reading of nearly zero and a reading of nearly 1023 when the pot is at it’s extreme positions.

The problem might be that I'm not using an Arduino Uno, but a Netduino, which only looks identical, but has a completely different software. And probably hardware, too. But since it looks identical and the pins are the same, I thought this joystick board would work.

The simple reason why I get 2.5 kOhm and not 10 kOhm is of course that all four pots (two joysticks on same board) are connected parallel between ground and 5 V. That makes 2.5 kOhm in total. And the sweeper really gives strange ohms when sweeping, due to the three other 10 kOhm pots.

I might have missed setting an internal resistor for the analog pin that the sweeper connects to. I kind of relied on having it there by default and the analog pin reading just voltages that would be independent of the current that runs through the analog pin.

Glad you figured it out. In-circuit measurements are prone to misleading results. Don't try to measure the resistance, it is a voltage divider circuit and it's best to measure the intended output, which is a voltage.

I guess there were two things that got me completely off the track. The more stupid thing is how the four 10k pots of the two joysticks are connected parallel to form a total resistance of 2.5 kOhm. And having one sweeper turn from one leg (0 V) to the other leg (5 V) really creates an upside down parabola starting from 0 kOhm, reaching 2.5 kOhm at sweeper position 33 %, 3.12 kOhm at 50 %, maximum 3.33 kOhm at 67% and finally 2.5 kOhm at 100 %. It just happened that this perfectly logical behaviour looked like how the actual measurements went, when my Netduino measured the voltage with my faulty code, which didn't pay respect for stray voltage.

In short, me failing with simple Ohm's Law things and stray voltage combined led me to think I had a faulty joystick board.

And I think I would have failed equally miserably using an Arduino Uno. Don't know, but I guess Arduino with its C/C++ is even faster than Netduino with its C#. So perhaps, at the time of polling, there's more stray voltage in the Arduino due to faster program loops. If no delays are added.

Hello all,
Another thing to remember is that the joystick mechanics do not
allow the pots to travel to their end points. They only move
about 25% of full rotation. You cannot get 0V or 5V output from
the joystick pots. And, because of differences between the
physical pots, these ‘end point’ voltages will most probably
be different for each pot. As stated earlier, the ‘stick centered’
reading will be close to 2.5V, but do not expect it be exactly that.
And, it will likely be different for each pot.
[Look at the pot and see how it is moved by the stick.]
{This is where <= and >= operators are your friends.}
Herb

I just did the voltage test. I measured the voltage with a multimeter while everything is attached and the Netduino is powered from the USB of my laptop. And each of the four pot sweepers really outputs everything from 0 V to 5 V. Though the rest voltages are 2.59 V, 2.50 V, 2.47 V and 2.54 V. After moving the joystick around for a while, I get exactly the same readings.

So I just have to focus on how I read the values in the code, allowing stray voltage to drain before reading. Thanks for helping out.

Johan_Ha,
You are correct! I should have measured my joystick
before posting my last. These are special trim pots
and they do allow 0V to 5V outputs on my UNO even
with the small rotation allowed by the mechanics.
Herb

Well, it wasn't the stray voltage thing. It was the Netduino itself. I should have read the specs more thoroughly. The analog pins read only up to 3.3 V. I connected the joystick to 3.3 V and now I get perfect readings from it.

Funny how the readings went up to 1023, when the voltage went up to 3.3 V and then dropped to something seemingly irregular above 512, when the voltage went over 3.3 V. Good thing I didn't toast the board with its own 5 V pin.

I'm glad you got it figured out. You sure could have fried your board, but the protection diodes kicked in. The pots on the board provided enough series resistance between the 5V and the input pin on the micro to keep too much current from flowing through the protection diodes built in to the micro.