How does a 4x4 Keypad work with PIC 16f877A?

  • Thread starter Thread starter kloong
  • Start date Start date
  • Tags Tags
    Work
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 7K views
Physics news on Phys.org
Normally, your inputs B0 through B3 are configured so that the internal pull-ups are on (that way, when you read these inputs, you see 5V, or a logic 1). You normally have the outputs B4-B7 set to 5V.

Now, when you want to scan a column, say, the first one, you set one of the outputs (in this case, B4) to 0V, logic 0.

You then read the inputs. If any of yhebuttons are pressed in this column, you'll read 0 on those pins. If buttons SW1 or SW9 were pressed, they would connect 0V across the button and you would read 0 on pins B0 and B2, and 1 on pins B1 and B3.

By successively setting each individual column to 0, and then reading the inputs to see which buttons are pressed in that row, you can figure out which buttons are pressed in the entire keypad.