4 x 4 keypad returning random keypress when nothing is pressed.

Hello everyone.

I'm using the keypad library (http://playground.arduino.cc/code/keypad) with a 4 x 4 membrane matrix keypad.

The problem I'm having is that when no key is pressed it still shows a random keypress on the serial monitor.

I don't know if my keyboard is just very sensitive or if my pins are floating.

I used this keypad successfully with a PIC in another project but in that library u used pull down resistors on my rows. Doing some looking around it looks like I need to use pull ups on my rows? Connect the rows to 5V with a resistor in order to eliminate the floating pins?

Now I'm guessing in software I could use the keystate function to only accept key presses after 50-100 ms.

Show us your schematic diagram and your code.
And you will need pullup or pulldown resistors. I don’t have the library installed to verify which. If pullups are needed, you could use the internal pullups. (The library might do this automatically.)

Edit: I just briefly read the documentation that you linked to. It says:-

You won’t need external resistors or diodes because the library uses the internal pullup resistors and additonally ensures that all unused column pins are high-impedance.

I think we’ll need to see your code…

Add pullup resistors, about 4k7 and see if the problem goes away. The internal pull-ups are very weak (~ 30k) for a remotely mounted switch where interference could be getting onto the wires.

Do you have long cable run? Do you have rats-nest wiring or something neat without big open loops?

I have the keypad connected directly to the ports 2-9.

My cables are a bit long if I include the ribbon from the keypad itself.

The pulldowns I used before where with 10k resistors but you mention I need something higher. Ill try that.

Ostrianiel: I have the keypad connected directly to the ports 2-9. My cables are a bit long if I include the ribbon from the keypad itself. The pulldowns I used before where with 10k resistors but you mention I need something higher. Ill try that.

10K should be OK, but 4K7 are even better. Then if it still plays up after adding 4K7 pullups to +5V, at least you definitely know that's not the problem.