Go Down

### Topic: Buttons using resistance value from ground (Read 1 time)previous topic - next topic

#### marklar

##### Jul 19, 2011, 10:02 pm
I took apart a stereo for the IR Receiver and in the process was able to get some other components working.  One is a broken out rotery encoder with three buttons.  I was able to get the rotery encoder working but the related buttons on the same break out board are connected to the ground of the rotery encoder.

I hooked up the resistors to an LED and was able to see the lighting difference but I am at a loss as to how to read that via an analog pin.

Is there a way I can read the resistance value of the grounds via an analog pin?

#### fkeel

#1
##### Jul 19, 2011, 10:10 pm

If I understand you correct (again, I wish I had something to look at... maybe post an image if my comment doesnt help):

Its a variable resistor rigth?

I suspect all you need to do is set up a voltage divider. The part which powers the LED goes into the analog input, have a pull down resistor running parallel to the sensor/variable resistor go to ground and connect both to the +5 Volts of your arduino.

(however I feel like I might be misunderstanding your question.)

p.
http://embodimentlabs.tumblr.com/
http://paulstrohmeier.info/

#### marklar

#2
##### Jul 20, 2011, 02:25 am
Thanks for the replies.

I thought it was pretty common to hook up multiple buttons with different resistors so that you can tell by the current which button was pressed by reading the current via an analog pin.  I have done this with standard buttons and resistors, but did it with a VCC not ground.  Now I have a break out board from a stereo with three buttons connected the same way, but also connected to a ground

INPUT
|
|---- button 1 -- R1 -- (out)
|
|---- button 2 -- R2 -- (out)
|
|---- button 3 -- R3 -- (out)

(all outs are connected as a single wire)

To describe it, there are 2 wires - one is input into the board and other is output from the board.  If no button is pressed, there is no current through the wire.  If a button is pressed, the resistor between the button and the output controls how much current flows.  When I power an LED with normal 5v and a resistor, it lights up full.  To test, I ran a wire from the ground/resistor to the input wire and output wire to ground on the LED.  This makes the ground end up running through all three buttons.  With no button pressed, the LED is off.  When I press button 1 the LED comes on dimmer than full, button 2 lights up the led lighter than 2 and button 3 even lighter.  This tells me that I should be able to read those current differences to know which button is pressed but can't figure out how to make it work when the connection is ground not VCC.

if not feasible I'll just ignore the buttons as this is just a learning experience.

Thank you.

#### marklar

#3
##### Jul 20, 2011, 04:05 am
Ahhh, a pull up resistor is the key - thank you.

This is a part from a stereo with SMD resistors built in, I added the pull up resistor and it works, I can tell which button is pressed - now it is that much more useful and I learned something important (the primary goal).  Thank you very much!

Go Up