Friday, December 28, 2012

Keyboard Activated Lockbox

The Arduino has great support for input devices, and I stumbled upon the Keypad library recently which triggered the idea of making a lockbox.  There are lots of Arduino based lockboxes out there already, so this one is derivative.  But it was a really nice gift for a couple of my coworkers who are math teachers... the solution to a word problem can be the code to open the lockbox into which students can submit their names or from which students can take a prize.

This is a pretty simple project.  The keypad has four pins for the rows and four pins for the columns.  The keypad I used is from Digikey, part number GH5011.  I used the nice crimping tool and parts from Hansen Hobbies to make a wiring harness to connect the keypad to the Arduino.  I used a standard 5V hobby servo to make a latching mechanism to hold the lockbox lid shut; the servo is driven by a pulse from the Arduino.  I used a separate 4.5V power supply for the servo, and a 9V power supply for the Arduino.  The Arduino can source 5V which could power a servo directly, but the current draw from the servo is probably more than should be sourced by the board.  See this thread for a more thorough description of limitation of the Arduino five volt supply.  An LED shows when the box is locked.

I again made really good usage of our school's laser cutter for this project, designing a custom box which nicely holds all the components together.  There are two DXF files which you can download to make the box out of 1/4" wood (except for the latch, which is made from 1/8" wood and press fit into the top of the box).

The code for this project can be downloaded here.  You can also look at the code by clicking on this link.  The keypad library makes it really easy to add any type of keypad and read a value passed to it.  My code uses an array to store a sequence of buttons that are pressed.  The size of the array is the same as the length of the code, so that the array always has the last "n" values pressed stored, where "n" is the length of the code.  When the special character "#" is pressed, the program compares each value of the array to each character in the code.  If they are all equal, the servo toggles its position, either opening or locking the box.

No comments:

Post a Comment