Team 1.2 – Schematics

3x4_Matrix_CircuitAbove is the main schematic we used for our project which helped us figure out what pins corresponded to which row and column as well as how a specific keys location was relayed to the board. The schematic details the conductors associated with each row and each column. The keypad we used for our project has 4 rows and 3 columns for 12 total buttons, but only 7 data pins. To read which button was pressed at any given time, we energized the voltage on each row while checking for a column inputs.

Here is a diagram of how each row and column was wired to the A3BU:keypad_hardware_schematic (1)

Team 1.2 – Keypad Lock

The intent of our final project was to create a keypad lock using a 12-key membrane keyboard and the XMEGA-A3BU board that would trigger a stepper motor to open a mechanical lock. We ran into a problem early on that forced us to change course slightly. The EasyDriver for the stepper motor we were planning on using for our lock did not arrive in time so we decided to go with an alternate driver. This ended poorly for us as the alternate driver caught fire during initial testing, much like our hopes and dreams.

As an alternative, we printed messages to the LCD while also flashing the onboard LEDs to signal that the provided password was correct or incorrect. We also implemented a menu system through which the user can either set or try a password. Passwords can be 10 digits or less, and are hashed upon entry for added security.  If the user attempts to try a password before one has been set, an error message is displayed and the user is returned to the main menu.

Team 1.2 – Code

codeblockWhat you see above is how we went about getting user input from the keypad. We initially set a row high then wait 50ms to ensure the voltage has a chance to ramp up to solid logic levels. We then check to see which column goes high. This tells us which key is pressed by creating a coordinate pair (row, column). We then set the row back low and move on to the next row. This continues until all rows (total of 4) have been set high and then low again.

This could be easily improved by moving the input handler to an interrupt service routine that gets called when changes are detected on the input pins. However, this would also require more time and consideration to pull off without it having adverse effects on the sequential flow of our program.