Shop OBEX P1 Docs P2 Docs Learn Events
Looking for someone to point me in the right direction with scanning inputs — Parallax Forums

Looking for someone to point me in the right direction with scanning inputs

JomsJoms Posts: 279
edited 2008-06-21 00:25 in BASIC Stamp
I have setup where I have 20 buttons, 5 rows each with 4 buttons in them.· I have logic pins 0,1,2,3 hooked across the columns and 4,5,6,7,8 across the rows with each of these pulled low using a 10K resistor.· What I am looking for is an example of setting outputs 0-3 high/low and reading the input on pins 4-8.· I have seen an example of this code a few weeks back somewhere but can't seem to find it now.· Does anyone have any ideas on where to start with the code?· Thanks in advance...

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-06-20 23:57
    I think one of the Nuts and Volts columns (#3 ?) discussed this. You can set pins 0-3 as a group with DIRA and OUTA. You can't read pins 4-8 as a group quite as easily. You want to set one of pins 0-3 to output high (use the DCD operator) and the others to input (high impedance), then read in pins 4-8 (like X = INS & %111110000). If it's zero, there are no keys down. If it's non-zero, you can use the NCD operator to give you the first bit that's a one. Now you have the row and column numbers and you can multiply them to get an index to look in a table or LOOKUP statement for the character.
  • ForrestForrest Posts: 1,341
    edited 2008-06-21 00:25
    Nuts & Volts #3 and #22 discuss how to handle scanning keypads. Download them here
    www.parallax.com/Resources/NutsVoltsColumns/NutsVoltsVolume1/tabid/444/Default.aspx

    For a slick solution that uses just 1 I/O Pin and one capacitor plus a resistor for each row and column, scroll down to the middle of this page
    http://forums.parallax.com/showthread.php?p=570329
Sign In or Register to comment.