Calculating a value resistors

Hello, What value resistor if I want to connect 6 or 7 or 8 switches?

Thank you

Attached link

You can continue to utilize 2k ohm resistors in any number in the series string. The only thing that will change is the digital conversion value returned with each single switch closure when you perform the analogRead() function.

By the way I feel the circuit would be more reliable if you wired the last connection of the far left resistor to the arduino +5vdc shield pin instead of relying on the analog input pin' internal pull-up resistor to supply the voltage source for the resistor string.


Thank you for the quick reply, If I will use 10K still I get different values???, or it will not work? Thank you

VMwareUser: Thank you for the quick reply, If I will use 10K still I get different values???, or it will not work? Thank you

Yes adding 10K resistors would work but the values you read from the analog input pin will not be of a uniform spacing (or step change) for the different switch activation. But as long as you know what values each switch closure creates you can adapt to those returned values in your program. Keep in mind that your program should not assume that a 'perfect' repeatable value will be returned with each time a specific switch is pressed, your coding should see if the value is within a range of values of each possible switch value, if that makes sense. If not you will probably have problems making your program operate reliably. For example, if a specific switch closure creates a digital count value of say 300 then your program should assume that any value returned from say 290-310 is still a valid value for that specific switch activation. How wide a range depends on how many switche steps are being used of course.


Thank you very much Lefty for the explanation.

Be carefull the reference document is the Atmel datasheet. For the Uno it's Atmega 328 datasheet: Inside there are some responces to your questions :

page 314: Electrical Characteristics Value of Internal pull-up resistor : Between 20k and 60k -> R= 40k +/- 50% !!!! (value depending on the batch) For accurate measurements it is preferable not to use them but to use an external resistor.

page 257 Analog-to-Digital Converter 23.6.1 -> Analog Input Circuitry: "The ADC is optimized for analog signals with output impedance of approximately 10 k or less." It is preferable that the highest value of "equivalent resistance" does not exceed 10k You can use higher values, there is no risk to the micro, but ??Atmell will not guarantee the result.

Thank you very much