Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

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

  1. Feb 26, 2010 #1
  2. jcsd
  3. Feb 26, 2010 #2


    User Avatar
    Science Advisor

    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.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

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