Tom Carroll Preston Linser Project Overview • Use keypad to receive 4 numbers from a user. • Compare these 4 numbers to a combination defined in the code. • If the combo is correct, light an LED. • If incorrect, play a tone through the speaker. • After a 4th incorrect combo, play a warning siren. Keypad • Sparkfun COM‐08653 • 12 keys: 3 columns x 4 rows • Keys are momentary switches • Make a connection between a row and a column • Requires current-limiting resistors and pull-up resistors. Keypad Issues • Mechanical switches bounce • Causes signal inconsistencies for a short period after switch is depressed • Can be addressed with hardware or software. • Set‐reset latch, CMOS gate debouncer, Integrating RC circuit debouncer, etc. • A short software delay (5‐20 ms) Keypad Issues • Holding down a key should only be interpreted as one keystroke. Create a variable to store keystroke data. Store the value of the last key that was pressed. • If no key was pressed, store a zero. • Once the key is released, return the variable to zero. • This tests for both depression and release of the key. • • Speaker • Use Pulse‐Width Modulation • Define a period corresponding to a desired tone frequency. • Set output pin high for half the period, then low for the remaining half. • Loop for desired duration of sound. Circuit Schematic Pseudocode – Main Loop Pseudocode – Key Test Pseudocode – Wrong Combo and Beep Pseudocode ‐ Alarm Alternate/Further Options • Use a distinct state machine structure. • After the 4th incorrect combo, lock the user out. • Implement a servo motor to control an actual lock. • Use HCS12 Pulse‐Width Modulation hardware. Questions?