Introduction: Detecting Door Close or Open Using Magnetic Door Switch

Picture of Detecting Door Close or Open Using Magnetic Door Switch

hey guys this instructable is to show how to use the seeed studio magnetic door switch..

Step 1: How It Works and Schematic

Picture of How It Works and Schematic

hi guys, have you ever wanted to detect if a door is closed or not and you had troubles finding that perfect little sensor to use, well search no more.

using the seeed studio magnetic door switch is the solution. its as simple has connecting a button to an analog pin but in this case we wont be connecting a button but the seeed studio's receiver(or the magnetic sensor...i want to believe its made up of a hall sensor).

connect one wire of the receiver to the analog pin and the other to the 5v pin of the arduino has shown in the schematic above.

thats all..

now the code.

Step 2: Step 2: the Code

ok so with the sensor hooked up to your arduino mind you any other arduino can be used(here we used the Uno)

you can type the following lines of code in the arduino ide..pls note im assuming you are a familiar with the arduino enviroment and know your way around an arduino.

here come the code...


int led = 13 ; // just using the led onboard the arduino as an indicator

int sensor = 5;

void setup()





void loop()


int val = analogRead(sensor);

if (val<900)





all right thats all you can hack the code and use as you want

thank you!!


tomatoskins (author)2015-10-13

I love reed switches! They are so handy with so many applications!

Eodunlade (author)tomatoskins2015-10-14

Handy is the word

Eodunlade (author)2015-10-14

Oh sorry guys, will change ASAP...thks

gregoryfenton (author)2015-10-13

The black wire (GND) is connected to the +5v rail.
Instant short circuit (which is bad).
Please edit the image to move the end of the black wire up to the correct location.

sithdeath (author)2015-10-13

just curious as to why the + & - are connected to the same track on the proto board?

About This Instructable




Bio: advancing the course of technology
More by Eodunlade:Detecting door close or open using magnetic door switch
Add instructable to: