Theory

Most alarm systems follow a basic design. A switch closure (or opening) triggers action by a central monitor and the alarm generates some form of annunciation.
The sensor blocks may actually be multiple sensors in one monitoring branch. Designs can be made which give only one indication the sensor chain has been triggered or if you have a more smart design, multiple sensors will provide individual indications.
Switches can be normally closed or normally open. When they are triggered, they change state (closed goes open, open goes closed). The monitoring unit notices the change and if it meets criteria that it believes is an alarm, it annunciates.

Annunciations can take as many forms as sensors. The stereotype alarm system has a very large horn to make an ear-splitting sound. But it can be much more subtle. The central monitor can alert a "silent alarm": making the alarm known in some way, either locally or far away. An example would be a text or SMS message on your phone stating an alarm has been triggered. The simplest alarm may only trigger a local alarm not designed to scare the intruder - this can be a nearby notification or it could be a record of alarm events for later review.

Multiple Sensors, One Pin

You can use nearly unlimited sensor switches if you place multiple switches in a branch. The branch can sense one switch out of all that may have changed state in a branch. In this manner you can only tell if any one of the multiple sensors in the branch has tripped. You can do this using normally open sensors in parallel or normally closed sensors in series. You can use both types of sensors putting the closed switches in line and the open switches in parallel. The resistor pulls the circuit high if the loop is opened otherwise the loop is grounded.
There are circuit methods that allow you to identify which switch in a branch was tripped if you use an analog pin. These use resistors to change the voltage values the analog pin reads. Typical "display shields" use this to read 4 to 6 switches to determine what was entered.

But many analog switch reading circuits have a problem: they cannot determine if two buttons are pressed at the same time. For a simple alarm system, this might not matter - an alarm happened but you only know it is on a specific branch. With a bit more circuit design, you can determine if multiple sensors have tripped on a single branch and which ones they were. The method most often in textbooks is the R-2R resistor ladder.

Here I will demonstrate a simplified design of my own, a parallel resistor system that uses less components and has good accuracy for Arduino-type analog inputs. The complexity grows with the number of sensors, so I will show for three sensors on a branch.
Normally the Analog Input A1 is pulled high by resistor R4. If any of the switches S1, S2, or S3 is closed, the resistance changes in a predetermined way. Circuit-wise, each of the resistors R1, R2, and R3 would add to the total resistance using the familiar circuit formula 1/R = 1/R1+1/R2+1/R3. All we have to do is measure the analog values read by the Trinket and add them to our code. This method also works equally well for normally open or normally closed switches.

This method does take only four resistors whereas the pure R-2R ladder method requires five to six resistors for 3 switches).
R-2R ladder (courtesy Wikipedia)

This guide was first published on Dec 31, 2013. It was last updated on Dec 31, 2013.

This page (Alarm Basics) was last updated on Nov 22, 2021.

Text editor powered by tinymce.