How to Use a Magnetic Door Switch / Sensor With Arduino
by codebender_cc in Circuits > Arduino
69563 Views, 53 Favorites, 0 Comments
How to Use a Magnetic Door Switch / Sensor With Arduino
![DSC_0026[1].jpg](/proxy/?url=https://content.instructables.com/FY8/THDC/IRG4HPG2/FY8THDCIRG4HPG2.jpg&filename=DSC_0026[1].jpg)
In this tutorial we will use one magnetic - contact door sw / sensor and a buzzer for making a "noise" when a door is opened. Normally the reed is 'open' (no connection between the two wires). The other half is a magnet. When the magnet is less than 13mm (0.5") away, the reed switch closes.
What You Will Need
![DSC_0027[1].jpg](/proxy/?url=https://content.instructables.com/FEE/BBH9/IRG4HPRF/FEEBBH9IRG4HPRF.jpg&filename=DSC_0027[1].jpg)
For this project you will need:
- Arduino uno
- Magnetic Contact Switch - Door Sensor
- Buzzer
- Breadboard and some cables
The Circuit

![DSC_0028[1].jpg](/proxy/?url=https://content.instructables.com/FY6/X8H9/IRG4HSLY/FY6X8H9IRG4HSLY.jpg&filename=DSC_0028[1].jpg)
The connections are pretty easy, see the above image with the breadboard circuit schematic.
The Code

Here's the code, embedded using Codebender!
Try downloading the Codebender plugin and clicking on the "Run on Arduino" button to program your Arduino board with this sketch. And that's it, you've programmed your Arduino with this sketch!
Well Done!
You have successfully completed one more "How to" tutorial and you learned how to use a magnetic contact switch with Arduino.
I hope you liked this, let me know in the comments.
There will be more of them, so make sure to click Follow button!