MK24 Reed Switch Door Sensor
Detect a door opening with a magnet, a tiny glass reed switch, and one Arduino digital pin — the building block of every burglar alarm.
Difficulty: Breadboard. Estimated build time: about 20 minutes. Estimated parts cost: about US$2.50. 5-line bill of materials. Compare supplier offers when available. A magnetically-triggered door sensor built from the Standex MK24-A-2, a glass-encapsulated reed switch about 14 mm long.
Wire the reed switch with a pull-up
One lead of the MK24 goes to GND. The other goes to Arduino digital pin D2 — and from D2 a 10 kΩ pull-up to V_CC. When no magnet is near, the contacts are open and the pin reads HIGH. When the magnet approaches, the contacts close and the pin reads LOW.
Read it in software with debouncing
Reed switches bounce just like mechanical buttons — a few milliseconds of chatter as the blades stop ringing. Use the standard millis()-based debounce idiom: track lastDebounceTime and only act when the state has been stable for 50 ms. Print “door opened” on rising edge and “door closed” on falling edge.
Add a magnet and find the operating distance
Glue a 5 mm × 5 mm × 2 mm N42 neodymium magnet on a small wooden “door” that slides past the reed switch. Find the gap at which the contact closes — typically 10–15 mm for the MK24-A-2. The blue stripe on the reed body marks the most sensitive axis.
Trigger a buzzer or push a notification
Wire a small active buzzer to D8 with a 220 Ω series resistor; chirp on any door-open event. Or pair the Arduino with an ESP32 over Serial and have the ESP32 push a notification when the front door opens after 11 PM. The same wiring style works for window sensors, fridge sensors, and mailbox sensors.