AnalogRead moving from 0V to 5V and back

Dear Community

I'm working on my fifth arduino project and I guess I left the beginner status behind me, although I am getting crazy with my actual problem and really hope someone is opening my eyes with a simple hint... :slight_smile:

I ordered a simple 4x4 membrane keypad (
I created a voltage divider by simply connecting 4 resistors (10k, serial), on one side 5V, other side to GND. So I'm getting beside 5V something like 3.7V, 2.4V, 1.1V between the resistors.

I connected the 4 rows of the membrane keypad with the different voltages, the colums to the analog inputs 0-3.
Then I used the sample to read the voltage (, which works great so far...

There is just one problem, when I do not press any button, the voltage increases from 0V to 5V every few seconds and is decreasing slowly to 0V again after almost a second on 5V????????

I tried two different boards, same problem. When I connect the AnalogPin to GND I am getting a clear solid 0 (sensor value, not yet converted to voltage) on one board, on the other I'm getting something arround 23 (from 1023 Max).

I double-checked my soldering... can it be that some bad soldering is causing that?

Thanks a lot for your help in advance


You have to ground the analog inputs with a pull down resistor, for example a 100kohm in your case. Otherwise the analog inputs float up and down based on electrical fields induced into your wires.

Sounds promising.. :slight_smile:

Where do I have to place the pull down resistor? I guess between GND an the analogInput right?

Thx a lot for your fast answer pito.

… one side of the pulldown resistor connected to an particular analog input on arduino, its other side connected to ground (GND)…
So with 4 analog inputs you need 4 resistors…

Pull-down resistor means - it helps a signal be weakly pulled to Ground (so it is most of the time, or when not driven, near the zero/gnd potential, or at logical zero)…
Pull-up resistor means - it helps a signal be weakly pulled to Vcc (so it is most of the time, or when not driven, near the Vcc potential, or at logical one)…

Dear Pito

Thank you very much. I'm lack of a 100k resistor, but I just tried it with a smaller one, looks good :slight_smile:

You made my day.

Yea, you may try with smaller, but the smaller the pulldown value the more will affect your analog reading (compared to the values without the pulldowns).
In case you would have a lot of noise on the analog readings when manipulating with the keyboard, you may connect a 10-100nF capacitor to each pulldown in parallel (so you need 4x cpacitors).
Have fun..