Detecting Door Close or Open Using Magnetic Door Switch


Introduction: Detecting Door Close or Open Using Magnetic Door Switch

About: advancing the course of technology

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

Step 1: 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!!



    • Make it Move Contest

      Make it Move Contest
    • Casting Contest

      Casting Contest
    • Clocks Contest

      Clocks Contest

    We have a be nice policy.
    Please be positive and constructive.




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

    1 reply

    Oh sorry guys, will change ASAP...thks

    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.

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