Magnetic Alarm with Keypad – Code

    

Here is the code that was written for this project. It takes an input from a Reed Sensor that is set high by the removal of a magnet. In turn, this causes the screen to turn on (as a visual output), a Piezo Buzzer to ‘alarm’ (via Pulse Modulation as an auditory output), and then accepts a ‘code’ from the keypad in order to disable the signal. Regrettable the keypad only appears to work sometimes, whether as a result of incomplete coding, or through the keypad itself being faulty. The keypad input is checked against a code that is existing as a character string, and then this in turn turns off the LCD and resets the alarm system after a delay to allow the magnet to be placed on the reed sensor once again. This could be used as a simple alarmed door system with a keyed disable.

Magnetic Alarm with Keypad – Schematic/Hardware Design

Here is the schematic and breadboard layout of our design. The Reed sensor and piezo buzzer each run off of five volts, and each has a signal going to/ coming from the A3BU. The Reed sensor provides a signal when a magnet is moved away from it, and the piezo buzzer produces an ‘annoying’ output when it receives an incoming pulse width modulation. The system will be reset with the keypad which runs off of a 4×3 matrix, for a total of 7 pins, using basic logic to match the pins to create the numbered inputs which will need to be defined in our code, or at least just mapped correctly.

Magnetic Alarm with Keypad – The big picture

Our group, Genuine Risk, have been working on creating a basic security system idea using a Reed sensor, a keypad, and a piezo buzzer. The idea is that the reed sensor could be placed in a door, on a window, or the like and be affected by a magnet in the moving portion. When the subject is opened, the reed sensor’s output goes high. The A3BU board then takes this input, and outputs a frequency to the piezo sensor, causing an alarm. A keypad can then be used to turn off the alarm, and after a delay, the security system will reset itself. Another post will be forthcoming tonight with the schematic and wiring.