EMBEDDED SYSTEMS & MICROCONTROLLERS · PAGE 68
Project: Keypad Door Alarm
Scan, compare, react.
A 4 by 3 keypad uses seven pins: drive one row low at a time and read the columns to find the pressed key. Debounce each press.
Store the typed digits in a small buffer and compare them with the stored code. Three wrong tries sound a buzzer and lock input for a minute.
A state machine with states Armed, Entering, Open and Alarm keeps the logic clear.