Calculating analogRead value 0-1023 form button and 2 resistors set

In this set:

5V -> Button -> 10 Ohm Resistor -> splitting into:

  • Line to analogIN
  • 270 Ohm -> GND

value from AnalogRead should be:

(1 - (10/(10+270)) * 1024 ~= 987

But for some reason I get value ~= 945

Is the equation wrong? Or maybe my Arduino UNO (clone) is corrupted somehow?

Or maybe I should use 100/2700 ohms resistors instead of 10/270 Ohm for better result?

Many thanks for help!

Resistors have tolerance ( commonly 2 or 5%) so your divider may not be what you think.
Those resistor values are low and maybe over loading your sensor output .
By default the ADC uses the 5v supply line as it’s reference. ( this is ok for you if you are using the same 5v to the button) .There is a more accurate internal reference of around 1.1v which is more stable.
Having said all that , usually you need to calibrate your A/D values any way to take out any tolerances.

What do you see if you take the button out of the circuit and just connect the resistor straight to 5V? It's not impossible that the button and any wiring have measurable resistance (if you're connecting things via breadboard then it's even more likely).

If you try it with 100/2.7K that will also minimise the effect of switch resistance.

Steve

Finally, after 10/270 failure

I have used 100/2700 resistors. the results was 5 points difference from my divider (equation).

After this I also have checked 1000/27000 which is even better, near 0-2 points of difference. So I will go with this scale of resistors. This will give me enough values for creating intervals for 20+ button per analog input.

I think I was overloading sensors but putting to much current.

Thanks!

mbedni:
Finally, after 10/270 failure

I have used 100/2700 resistors. the results was 5 points difference from my divider (equation).

After this I also have checked 1000/27000 which is even better, near 0-2 points of difference. So I will go with this scale of resistors. This will give me enough values for creating intervals for 20+ button per analog input.

I think I was overloading sensors but putting to much current.

Thanks!

Or, the most likely cause of issue was that, too low of a resistor divider input network total resistance, changed the input impedance of the A:D converter.

Idahowalker:
Or, the most likely cause of issue was that, too low of a resistor divider input network total resistance, changed the input impedance of the A:D converter.

No, that makes no sense at all, the input impedance of anything is a property of the thing and nothing
else.

The problem was the presence of non-trivial resistance between Vcc and the output of the switch,
due to switch contact resistance, or wiring, or other loads on the same wiring creating IR loss
voltages across the wiring. (The latter is more likely I think).

It could also be that a different 5V supply from the Arduino Vcc was being used to the switch,
which of course will give erroneous readings as the ADC inputs are ratiometric to the AVcc or
AREF pin, depending on analogReference() mode