Resistor analog values changing

so i'm doing this.... (multiple buttons with 1 analog) Multiple Buttons on 1 analog pin - Exhibition - Arduino Forum

i got it working with 1analog = 10buttons and 30 buttons all in all so that is 3 analog pins used...

all was well and the if-else statement of the code like this....

 if (btnSet0 >= 1011) { unitNumber = 1;  }
else if (btnSet0 >= 780 && btnSet0 < 820) { unitNumber = 2; }
else if (btnSet0 >= 970 && btnSet0 < 1010) { unitNumber = 3; }
else if (btnSet0 >= 888 && btnSet0 < 928) { unitNumber = 4; }
else if (btnSet0 >= 695 && btnSet0 < 739) { unitNumber = 5; }
else if (btnSet0 >= 583 && btnSet0 < 660) { unitNumber = 6; }
else if (btnSet0 >= 381 && btnSet0 < 421) { unitNumber = 7; }
else if (btnSet0 >= 187 && btnSet0 < 227) { unitNumber = 8; }
else if (btnSet0 >= 85 && btnSet0 < 125) { unitNumber = 9; }
else if (btnSet0 >= 10 && btnSet0 < 52) { unitNumber = 10; }

my problem is i don't know why the values changed, causing some buttons to NOT set it to the unitNumber properly...

is this caused by fluctuating voltages? because my voltage should be stable is the power comes from 12v -> 7805 regulator -> 5v output...

i could try and adjust the range again (3rd time) but at least i need to know what's causing this....

My guess (I can't see a picture of your project) is that your probably using multi-conductor cable with soldered terminations at 0.1" spacing and this is where semi-conductive solder residue is causing cross-talk, leakage fluctuation and increased sensitivity to humidity and noise. Combine this with resistor tolerance, power supply regulation and noise and I wonder what the overall tolerance would be. I suspect you would see overlap in threshold levels when building 3 different circuits of 10 buttons.

Any more details on your project? (schematic and pictures)

Maybe I am Wrong

A lot of the Arduino Add-Ons come from China.
When everything worked well before you had a problem,
then the hardware and your code was OK.

If you did not change the code .... what can it be?

My rotary encoder made in China gave me problems after a while.
I was lucky to eliminate the problems with software.

The problem is to find out what is wrong.