Button over two resistors

Hello there. This is my first post, but I really don't find anything on my problem. This is sure a easy question. I have a joystick with 3 buttons which I want to connect to my arduino, but the buttons don't just close my circuit. The button press changes the resistance from 18 kO to 3kO by two resistors in series. I tried to connect this like a normal button input with pulldown, but this doesn't work. I made a shematic for you for reference.


How do I need to connect this and how needs my script to look like?
Thanks in advance. I dont know why but this confuses me a lot.

Is G and H the only wires that go outside your joystick?
Or does it share a common ground (and or common+) with other parts of your joystick?

G and H are cables coming directly from one button. The three buttons are identical and dont share a common ground or +.

They also have identical resistance?

Yes the buttons are identical. I just connectet one button (two cables) for testing by now.

Then you can connect H to +, G to analogpin and Analogpin to ground via 15k resistor.
Via analogRead() you should get clearly different readings upon pushing the button.

1 Like

Use a analog input to start with.

When writing this post, I noticed that build_1971 would do it slightly different than me. It is trivial, but I give my thoughts anyway:
It is best to connect one pin of the switch to GND, to reduce electric noise.
So 'H' to GND and G to a analog input and a resistor of 10k from the analog input to 5V (or 3.3V on a 3.3V board). Use analogRead() and see which values you get.

It might be possible to use a digital input, but then we have to know your board to calculate the margins.

Could you use the notation: 3k or 3kOhm or 3kΩ. When I read you questions it feels as if just put the resistor knock out. We use "3k" for a 3.0 kΩ resistor.

1 Like

Ok. I guess I tried that in my countless attempts, but I'll try again on monday and let you know. Can you briefly explain why another 10-15k resistor is needed here?

A analog input reads a voltage, not a current, not a resistance.
You have turn the resistors somehow into a voltage. With a resistor to 5V (or 3.3V on a 3.3V board) and another resistor to GND, the voltage at the analog input will change when the button is pressed and a resistor is short circuit.

1 Like

Thanks guys. That works flawlessly.

why the hell you need something like that when one resistor or INPUT_PULLUP exist

@gaouser that is inside the joystick, so that is what we deal with. I suppose you want @eselphilip to remove those resistors ? That is possible, but not needed.
I don't know why the manufacturer made it that way. Sometimes resistors can select different modes or to identify different devices.

Koepel already explained why the resistor is needed.
A value of 10 to 15 kOhm is close to the resistance of your joystick. Therefore the measured Voltage difference between button pressed and button released will be high. Other values will also work, since analogRead can distinguish quite small differences. It would not surprise me that any value from 330 Ohm till 100 kOhm will work. The extremes might be susceptible to disturbances from nearby changing magnetic fields (motors, relais, motor controllers, spark plugs, strong radio transmitters) though.
You could put both your buttons in series. One end to plus, one end to ground and measure the middle. That way you can sense two buttons with one analog pin.
Maybe add an extra resistor with one of them. Otherwise there is no difference between both buttons pressed and no button pressed.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.