
A reed switch senses magnets the mechanical way, opening or closing a pair of physical contacts when a magnetic field gets close — a completely different mechanism from the solid-state Hall effect sensor we've covered before, even though both end up detecting "a magnet is nearby."
How it works
Inside a reed switch are two thin, magnetically responsive metal contacts sealed inside a glass tube. When a magnet approaches, those contacts either pull together (closing the circuit) or, in a normally-closed variant, separate (opening it) — a purely mechanical response with no electronics involved in the sensing itself.
Components needed
An Arduino Uno, a reed switch module, an LED, and jumper wires.
Wiring it up
The module connects to 5V and ground, with its digital output going to pin 8 and its analog output to A0. Arduino's built-in LED on pin 13 serves as an on-board visual indicator alongside any external LED.
Programming it
The sketch reads both the digital and analog values continuously, printing them to the Serial Monitor roughly every 100 milliseconds. An onboard potentiometer sets a sensitivity threshold — when the reading crosses it, the LED turns on, signaling that a magnet is close enough to trigger the switch.
How this compares to the Hall effect sensor
The Hall sensor we covered before is a solid-state component with no moving parts, reacting instantly and wearing out very slowly. A reed switch is mechanical — it physically opens and closes — which makes it simpler and cheaper but also means it can wear out after enough cycles and typically reacts a bit slower. In practice, either fits things like door and window contact sensors, but the reed switch's simplicity and low cost make it the more common choice for that specific job.
You can find reed switch magnetic sensor modules at Juthour Tech.
اترك تعليقا