I'm working on adding one of those ubiquitous, cheap, 4x4 matrix keypads to my Ben Eater build.
The good news is, it works. (So far at least!) But maybe that's just due to dumb luck? I'm still very much a learner when it comes to hardware, so I'm not sure I'm using the best design. Here's what I'm doing:
- The four "column" pins of the keypad are connected to PA0-3 on the VIA (65C22), which are configured as inputs. I also have them pulled low using 1K ohm resistors.
- The four "row" pins are connected to PA4-7 on the VIA, configured as outputs. No pullups or pulldowns.
- To scan, I'm setting each output pin in sequence by writing the appropriate value to the port, then checking the input from the same port to see if any of bits 0-3 are on. I'm also doing some simple software debouncing.
- Are the pull-down resistors necessary? If so, does 1K seem like a good value (I just sort of guessed)?
- In a discussion on Reddit, someone mentioned that the older 6522 (no "C" in it) worked differently and needed the inputs to be pulled up or something like that. The scanning then works in reverse, pulling one line low and checking for low inputs instead of high. Would that be a better way to go, even with the 65C22? Or maybe to make the whole design compatible with either chip?
- Basically, am I on the right track at all here?
- Jeff