This module covers the circuitry and code involved in creating a simple keypad-based lock mechanism. It will first go over the circuitry of wiring up the keypad, the 4-digit 7-segment display, and an indicator LED. The next part covers writing all of the code to run this system. At the end, you will be able to type in a code, see it appear on the display, press A to submit it, and see the LED turn on it you got the code right.
To detect which button is pressed, the Raspberry Pi has to send a pulse to each of the four rows of the keyboard. When a user presses a button that’s connected to the line which is currently pulled high, the corresponding column is also pulled high.
By decoding the combination of line and column, you can determine which button got pressed.
If a user, for example, presses the B button located on the second row in the fourth column, the Raspberry Pi detects this button press when it sends a pulse to the second line and then checks which of the four columns was pulled high.