TK41DIGITALbeginner

Reed Switch

Two contacts sealed in glass that close near a magnet. The window sensor in every alarm system, and it needs no power to do its job.

Comes in this kit — not sold separately

Specifications

TypeReed switch, normally open
ActuationMagnetic, no contact
Pull-upFitted on the module
Supply voltage3.3 V or 5 V

What it is

Two ferrous contacts in a sealed glass tube. A magnet nearby magnetises them, they attract each other, and the circuit closes.

It is a switch, so unlike TK18 there is no semiconductor and no quiescent current — the switching itself takes no power at all. Sealed in glass, it works in damp and dusty places where an exposed contact would corrode.

Compared with the Hall sensor: the reed switch is not polarity-sensitive (either pole works), tolerates a wider gap, and costs less. What it gives up is speed and life — the contacts are mechanical, they bounce, and they eventually wear out, which makes it wrong for counting a spinning wheel.

Reed Switch — front
Front
Reed Switch — back
Back
Reed Switch — side
Side

Pinout

  • GND (negative): Like the negative terminal (-) of a battery, connect to the control board's GND
  • VCC (positive): Like the positive terminal (+) of a battery, connect to the control board's 3.3V or 5V (this module supports both 3.3V and 5V)
  • NC (no connection): No actual circuit connection, included for unified interface, can be left unconnected
  • SIGNAL (signal output): Magnetic field detection output pin, connect to the control board's digital pin (e.g. Arduino D2 or Pico GPIO 0)
    • Outputs HIGH (HIGH/1) when magnetic field is detected
    • Outputs LOW (LOW/0) when no magnetic field is detected

Wiring

Reed Switch wiring

  1. GND → Control board GND
  2. VCC → Control board 3.3V or 5V
  3. SIGNAL → Control board digital pin (use the pin defined in your program)

Example

// Pin number: change this to match your wiring
#define REED_PIN 2   // Arduino digital pin connected to SIGNAL (e.g. D2)
#define LED_PIN 13   // LED pin (Arduino built-in LED on pin 13, or external LED)

void setup() {
  // Initialize pin modes
  pinMode(REED_PIN, INPUT);   // Set magnetic switch pin as input (to read detection state)
  pinMode(LED_PIN, OUTPUT);   // Set LED pin as output (to control LED on/off)
  
  // Start serial for debugging (9600 baud)
  Serial.begin(9600);
  
  Serial.println("Magnetic switch program started");
  Serial.println("LED on when magnetic field detected, LED off when no magnetic field");
}

void loop() {
  // Read magnetic switch state
  int reedState = digitalRead(REED_PIN);  // Read switch pin level: HIGH(1) = magnetic field detected, LOW(0) = no magnetic field
  
  // Control LED based on detection state
  if (reedState == HIGH) {
    // Magnetic field detected: LED on
    digitalWrite(LED_PIN, HIGH);
    Serial.println("Magnetic field detected - LED on");
  } else {
    // No magnetic field detected: LED off
    digitalWrite(LED_PIN, LOW);
    Serial.println("No magnetic field detected - LED off");
  }
  
  delay(100);  // Brief delay to avoid reading too fast
}
Reed Switch running on an Arduino Uno

When it doesn’t work

It chatters as the magnet approaches.
Mechanical contacts bounce, and near the threshold they hover. Debounce for 30 ms, and mount the magnet so it passes decisively rather than creeping up.
The glass tube broke.
They are fragile and they do not survive being bent at the leads. Support the body, not the wires.
Can I count wheel rotations with it?
Not for long. Reed contacts are rated for a finite number of operations; a wheel sensor will exhaust one. Use TK18 or TK61.

Edit this page — content/modules/reed-switch.mdx

Community

Questions about this product

See what other owners have asked, and read their solutions.

Ask a question ↗

Reed Switch

Loading discussions…

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse Modules and blocks on the forum