Reed Switch
A magnetically-operated switch — its contacts close when a magnet is near.
How it works
A reed switch is two thin metal contacts sealed in a glass tube. Bring a magnet close and they snap together; move it away and they spring apart. That makes it perfect for door/window sensors — magnet on the door, switch on the frame.
Wire it exactly like a button: one side to a digital pin with INPUT_PULLUP, the other to GND. With the magnet present the pin reads LOW; remove the magnet (open the door) and it reads HIGH.
Pins
- Leg 1
- To a digital pin (INPUT_PULLUP).
- Leg 2
- To GND.
Ratings
- Action
- Closes near a magnet
- Read
- INPUT_PULLUP (closed = LOW)
Tips
- Glass-tube reeds are fragile — modules add a sturdier housing and pull-up.
- Mount the magnet on the moving part, the switch on the fixed part.