Intro: 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
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.
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 ...you 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;
int val = analogRead(sensor);
all right thats all you can hack the code and use as you want