I found many schematics out there for a 4x4 keyboard/switch matrix, both with and without diodes.

Yet I don't get it. If one doesn't add pull-down resistors, rows 1 to 4 will all be floating.

Can someone explain why pull down resistors they are not required in this case?

I plan to use an atmega32u4 microcontroller.

enter image description here

  • 1
    \$\begingroup\$ The direction flag on the column names should show inputs (point the other way), then it would probably be a little clearer. The rows need to be scanned one at a time to determine which switch is active in each row (set output, read each column, clear output). \$\endgroup\$
    – Ron Beyer
    Commented Apr 27, 2021 at 20:09
  • 1
    \$\begingroup\$ thx Ron, but why active low instead of active high ? any reason for this ? \$\endgroup\$ Commented Apr 27, 2021 at 20:17
  • 4
    \$\begingroup\$ @user7082181 - Hi, Please don't be offended at polite suggestions. Your site profile doesn't indicate that you're not a native English speaker. The comment you replied to, linked to part of the site help center, in case you could follow those recommendations. Also there is a site Code of Conduct requiring everyone to be kind & respectful. Your comment was (understandably) flagged as unkind, so I have deleted it - as well as the comment you responded to, as it has served its purpose to inform you of that recommendation. So it's now a clean slate. \$\endgroup\$
    – SamGibson
    Commented Apr 27, 2021 at 21:03

2 Answers 2


The way that you perform one scan of a keyboard like that goes like this:

  • Pull row 1 low, all other rows high. Read the column nibble.
  • Pull row 2 low, all other rows high. Read the column nibble.
  • Pull row 3 low, all other rows high. Read the column nibble.
  • Pull row 4 low, all other rows high. Read the column nibble.
  • Combine the four nibbles into 16 key presses (a low bit = key pressed).

The rows are pulled low by the hardware external to the keyboard (in this case, by the microcontroller's GPIO).

  • 1
    \$\begingroup\$ And use some method to debounce. :) \$\endgroup\$
    – jonk
    Commented Apr 27, 2021 at 20:28
  • 4
    \$\begingroup\$ WWWWhy wwwould I wwwwwant to do that? \$\endgroup\$
    – TimWescott
    Commented Apr 27, 2021 at 20:41
  • 3
    \$\begingroup\$ You might leave all four row drivers idling at logic "low". This allows the four column inputs to generate an interrupt-on-change when you hit any key. Then you proceed with Tim's scanning procedure, only allowing one-row-low at a time. \$\endgroup\$
    – glen_geek
    Commented Apr 27, 2021 at 21:39

Because the rows are outputs, resistors are not needed.

In fact, since AVR microcontrollers have inputs with internal pull-ups, the resistors on the columns are not needed either.

  • \$\begingroup\$ ok so we're talking open drains right ? \$\endgroup\$ Commented Apr 27, 2021 at 20:19
  • 2
    \$\begingroup\$ No, I wasn't, but now that you mentioned it, it does not matter if it is an open drain output or push pull output. \$\endgroup\$
    – Justme
    Commented Apr 27, 2021 at 20:26
  • \$\begingroup\$ To be clear, the MCU row driver outputs can be push-pull because the keypad has key diodes. Without key diodes, you'd use open-drain drivers as multiple presses in a column will connect drivers together. \$\endgroup\$
    – TonyM
    Commented Apr 27, 2021 at 22:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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