Skip to content

Connecting a magnetic reed door switch into arduino

Reed switch

A magnetic reed switch is a switch that change it's state whenever a magnetic field is present.
Magnetic reeds are cheap and really easy to find online.
They have a lot of practical uses like checking if a window/door is open or not.
We will use them in our A-H-A project.
There are two options of these magnetic switches.
The N.O. (normally open) and the N.C. (Normally Closed) ones.
Normally Closed (NC) is a reed switch that the current passes when the magnet is not present.
The same type of reed is also called Normally Open with magnet.
On the other hand a reed switch is called NO, when without the presence of a magnetic field the current does not pass (open circuit).
The same type of reed switch can be also called Normally Closed with magnet.
In alarms it is most common to use a NO or alternatively called NC with magnet reed switch since the alarm when is broken or being cut by thieves then the circuit results open/broken even if the magnet (door) is in place.

Reed Switches
Reed Switches

That's why most residential alarm systems use NO or alternatively called NC with magnet reed switches.
More about reed switched will be discussed in other theoretical articles. If you are interested you can visit the dedicated wikipedia page.
Let's find out how we can connect this switch into an arduino board.

The first thing to do is to find the type of our reed switch.
We take away the magnet (the part without the wires).
Now with a multimeter we measure the resistance between the two wire leads.
If the resistance is low (a couple of ohms) then our reed switch is a NC one (NO with magnet), on the other hand if by removing the magnet the resistance between the leads is high then the we have a NO switch (NC with magnet).
If you plan to construct the AHA project then stick with a NO (NC with magnet) reed switch.

The reed switch is nothing else than a normal switch. The connection with the arduino is identical with the pushbutton example.


The only difference is that we are going to use in this demo the digital port 6 instead the port 12.
As R1 we are going to use a 10K resistor

Below is a video demonstration on how to detect a NO/NC reed switch using the "continuity" option of your multimeter

In the next page we will post a simple code testing the NC reed switch