I know this sounds simple, but I have an Arduino Mega 2560 and I am making a matrix keypad for a claw machine. It's a 3*4 matrix keypad. Let's just say, I am making this keypad for the claw machine to reduce the number of I/O pins. I have tried to use a mux, but that has failed me because it has a single input/output pin and can only read ONE button at a time. So, I have come up with the solution to use a matrix keypad because: A. It is the most common method and B. It is smaller on a PCB design rather than that CD4067BE chip. The reason why I was trying to use that chip in the first place was because it included all my thirteen buttons. Basically, what I am wanting to know is if I should use a resistor or an LED to stop either "floating" or "ghosting." I still don't really know the difference between the two terms, but if somebody could clarify that, that would be great. And also when I should use an LED or a resistor. Or do they serve the same purpose? Tutorials: LED "ghosting" Pullup Resistor "floating" (I am not sure how to make a schematic of the "floating" pin). Schematic for the project (Credit to EasyEDA for the schematic). Thanks,


  • An LED is a diode, but a diode isn't an LED. Note also that matrix keyboards also scan (each row, for example, in the example you link to). I'm still puzzled what human you're targeting that can push buttons faster than an Arduino can scan them. Jun 15, 2021 at 15:33
  • But, isn't this approach faster? Won't I get a smoother stepper motor ride from them? So, what am I supposed to do about reducing the number of I/O pins from the claw machine?
    – Austin
    Jun 15, 2021 at 15:40
  • Thanks for the fast reply, too.
    – Austin
    Jun 15, 2021 at 15:41
  • ... You're talking about a difference of microseconds. There are a million microseconds in a second. Humans operate in tenths of seconds. A tenth of a second is one hundred thousand microseconds. No human can even perceive, let alone care about, the difference. There are hundreds of examples on making keyboards--just follow one. Jun 15, 2021 at 15:47
  • 1
    try going with the matrix arrangement ... if it does not work as expected, then go to direct connection, one switch, one pin .... playground.arduino.cc/Code/Keypad
    – jsotola
    Jun 15, 2021 at 17:34

1 Answer 1


First some clarification:

  • Floating is where an input isn't connected to a defined logic state. It's neither in one state or the other and is free to "float" between them at will. Basically a floating input is an antenna.
  • Ghosting is where you press two buttons in a matrix together and it causes unwanted short or crossed circuits in the matrix making it appear that other keys are pressed when they aren't.

The Keypad.h library deals with any pullups that may be needed. To prevent ghosting you need to use diodes (not LEDs) to separate the buttons from each other.

Nick Gammon has a fantastic tutorial where he describes the problems and solutions to ghosting.

  • So, why can't I use LEDs, does it have to "absorb" more, I guess? Does the Keypad library have internal pullup resistors?
    – Austin
    Jun 15, 2021 at 18:07
  • How come the row pins don't have a resistor?
    – Austin
    Jun 15, 2021 at 18:21
  • 1
    @Austin Libraries have code; hardware has pullup resistors. Because the rows are outputs--only the columns are read. A press is determined by outputting a value on a row and reading all the columns. Read all the way to the bottom :) Jun 15, 2021 at 18:24
  • That is a good article! Jun 15, 2021 at 18:27
  • 1
    LEDs have a massive forward voltage compared to proper diodes. They're also bigger, more power hungry and more expensive.
    – Majenko
    Jun 15, 2021 at 18:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.