Righty-ho. That's a big long title, and this is going to be a big long topic. What we are going to do is build a burglar alarm bit by bit. Then we're going to test it, review it, make any necessary changes and move to the next bit. This is called the design process, and if you've been following all the preceding chapters about the Arduino on this website you'll realise it's something we've been gradually building up to for ages. This topic will greatly beneit you if you are about to go on a design course, an electronic systems course, or just generally want to invent things with your Arduino or other micro-controllers as it starts from the very beginning of the process of invention.


In design, you always get a brief to which you must work. Here's ours:


  • Construct a multi-zone burglar alarm control system for a small commercial property.


  • The siren is to be an external system using its own power based on a rechargable battery and 240V mains power. This does not need to be designed. The function of the control system is to send a 5V signal  to activate and deactivate the noise of the siren.


  • The control system will ideally be powered by a UPS so that in the event of a power cut the control system will still work. Therefore at all points as little power as possible must be consumed by the system. It is not required for you to design the UPS.


  • The alarm control must have numerous zones to which triggers can be fitted. Each zone must be capable of being armed and disarmed independently of the others. Three windows and two doors must be considered, as well as the stockroom's warehouse door, the manager's office, the cash office and two fire exits.


  • There is also a high-value stockroom that is normally locked at all times(except when stock is being put away or retrieved) that should be protected. During trading hours, this should sound an alert when the door is opened but not cause the siren to activate. The alert is disabled by the same code that activates/deactivates the alarm. When the premises are closed, the opening of the high-value stockroom door causes the siren to activate.The same is true of the two fire exits.


  • The alarm control must have a four-digit code which is entered by a  keypad. This code must be entered by an operator to activate/deactivate  the system, and to change any independent settings. Once independent settings have been changed a one-push button logs out the user, but before final log-out the user is asked if he/she is sure they want to log out.


  • The four digit code must be at installation 0000 and must be changeable on request. The code may only be changed on input of the old code.


  • There must be a visual display and an audible tone when keys are pressed.


  • On closing the premises, the system must perform a self-assessment and warn if any areas are already breached by carelessly placed stock or a door left open, etc. If there are no breaches, then            the system should report so.


  • In the morning, the staff enter by one door and leave in the evening by the same door. This door should not be active until everybody has gone and the door is closed at night and should be rendered inactive in the morning by means of a device that can be employed before the door is opened. Once the device is activated in the morning, 30-60 seconds should be allowed to input the code to the panel before the siren activates, but only if the door has been opened. Otherwise the device should reset itself.


  • There must be a test facility for all zones that does not cause the siren to sound. The test facility should send reports to the display.


  • There should be a data logger on removable media. This media should be able to be removed from the system as required and should note date, time and zone activated.This should be able to be read by a PC.




Hmmm. The more bullet points you see on a brief, the more complex the thing is going to be and the more problems you are going to have to tackle. Even glancing at it it is obvious that the microcontroller code is going to have to be tight and the power consumption even tighter. So, twelve bullet points on that monster. Where do we start? Well, first we start by choosing a microcontroller to be at the heart of the system. We know that's going to be an Arduino. Problem 1 out of the way. Next we'll have to get up and running a user interface, because until we've done that we can't do anything else. Okay, the brief says:


The alarm control must have a four-digit code which is entered by a  keypad.




There must be a visual display and an audible tone when keys are pressed.



Right. We know what direction we're heading in now. Let's ignore the audible tones for the time being and get the visual up and running. (We'll put the key beeps in afterwards).


We need:  


1. A microcontroller   2. An LCD display   and  3. A matrix keypad.


Let's start with an UNO. We can hook them together like this:


Building, Testing and Developing a System with the Arduino and Other Devices.


If you click on this drawing it will pop up

slightly bigger.......

The keypad I am using here came from Proto-Pic and has nine pins in the interface. If you look at it as above, pin 1 is on the left and pin 9 on the right. Pin 1 and 9 do nothing as far as the keypad's workings are concerned. Some pads do not have them, and have only seven holes, and if you've got one with only seven holes then consider the first one along to be pin 2 for the purposes of this exercise. Most matrix pads work to the same standards and depend on a conductive path between a row and a column. Some are non-standard. If you have a non-standard you'll have to refer to your data sheet. If you don't know how to work a matrix pad, a HUGE article about it can be reached by clicking the link button on the left. Have a read through it and I promise you will know all about them after that.


Now, the above schematic is a tad packed. To avoid confusion, here's a table of where the keypad pins and the Arduino pins connect.


Click the button below to learn about matrix keypads:

You will notice that there are four resistors, one each attached to pins 3, 5, 7 and 8. These four pins are outputting to your Arduino. The signal has to be reliably low when no buttons on the keypad are being pressed or else you will get false readings from your keypad. Make your resistors ~ 560 ohms.


All the other keyboard pins are supplying an output from your Arduino to the keyboard. When you press a button on a row, one of them will go low and briefly disrupt the signal and the Arduino detects it. Which goes low depends on the column position of the button you press. This is the principle of digital signalling and it's how the Arduino knows which button you've pressed.

So, we've got a basic I/0 system wired. What we need now is a sketch to drive the Arduino to test it with.

What we are going to do at this early stage is to make the LCD display show the number that we've pressed on the keypad. Over the page we go for the code to upload to your Arduino.


This is going to be a very long and convoluted topic. I expect it to be anywhere between now and the end of July before this gets finished completely. Currently it's at the stage where a bug has introduced itself to the software of the interface, but I think I've found it and we now have fifteen pages.