Arduino Uno Reed Switch Module: Professional Magnetic Field Detection

Complete Arduino Uno reed switch module implementation on digital pin 2 with interrupt-driven edge detection. Industrial door/window security, proximity sensing, magnetic position encoders, and tamper detection with hermetically sealed magnetic contacts, 1-5cm N52 neodymium detection range, and 10-year MTBF.

Arduino Uno Reed Switch Module: Industrial Magnetic Position Sensing

Professional reed switch module contains hermetically sealed glass-enclosed ferromagnetic contacts that close (<0.5Ω) in 0.2ms when N52 neodymium magnets pass within 1-5cm detection envelope. Unlike Hall sensors, zero power consumption in open state enables battery-powered door alarms with 10+ year life.

Digital pin 2 interrupt captures instantaneous state changes with LM393 comparator providing clean 5V TTL output. Sensitivity pot adjusts 10-50 gauss trigger threshold. 3.3-5V operation, <1μA quiescent current.

Production Magnetic Sensing Components

  • Arduino UNO R3 interrupt capable (pin 2)
  • Reed Switch Sensor Module (glass reed)
  • N52 Neodymium test magnet (10x3mm)
  • Male-to-male jumper wires (3 pieces)
  • Solderless breadboard prototyping
  • 220Ω alarm LED + buzzer driver

Minimal 3-Wire Magnetic Interface

VCC: Arduino 5V (3.3-5V tolerant)

GND: Arduino GND

DO: Arduino Digital Pin 2 (HIGH = magnet detected)

Blue pot CW increases sensitivity (10→50 gauss). Red LED indicates trigger state.

Program: Arduino Uno Reed Switch - Security Door Alarm System
// Arduino Uno Reed Switch Module - Professional Security Implementation
// Pin 2: HIGH=magnet detected (door/window closed), interrupt driven
const int reedPin = 2;
const int alarmPin = 8;
const int statusLed = 13;

volatile bool magnetDetected = false;
volatile unsigned long breachStart = 0;
int eventCount = 0;

void setup() {
  Serial.begin(9600);
  pinMode(reedPin, INPUT);
  pinMode(alarmPin, OUTPUT);
  pinMode(statusLed, OUTPUT);
  
  attachInterrupt(digitalPinToInterrupt(reedPin), reedISR, CHANGE);
  
  Serial.println("=== Reed Switch Security System Active ===");
  Serial.println("Door/Window monitoring - tamper detection enabled");
}

void loop() {
  if(magnetDetected) {
    unsigned long breachDuration = millis() - breachStart;
    
    Serial.print("SECURITY BREACH #");
    Serial.print(++eventCount);
    Serial.print(" | Duration: ");
    Serial.print(breachDuration/1000);
    Serial.println("s");
    
    // Extended breach triggers siren
    if(breachDuration > 3000) {
      digitalWrite(alarmPin, HIGH);
      tone(9, 2000, 500);
    }
    
    magnetDetected = false;
  } else {
    digitalWrite(alarmPin, LOW);
  }
  
  delay(100);
}

void reedISR() {
  if(digitalRead(reedPin) == HIGH) {
    digitalWrite(statusLed, HIGH);
    Serial.println("DOOR SECURE (magnet aligned)");
  } else {
    digitalWrite(statusLed, LOW);
    breachStart = millis();
    magnetDetected = true;
    Serial.println("*** DOOR OPEN (breach detected) ***");
  }
}

Interrupt-Driven Production Deployment

Upload security monitoring firmware with tamper detection. Test with N52 magnet at 1-5cm range.

Serial Monitor logs breach events with duration tracking and alarm escalation.

Advanced Position Encoding & Conveyor Counting

Program: Arduino Uno Reed Switch - Magnetic Encoder
// Linear encoder with direction detection
const int reedA = 2;
const int reedB = 3;
volatile long position = 0;

void reedISR() {
  static bool lastA = false;
  bool stateA = digitalRead(reedA);
  bool stateB = digitalRead(reedB);
  
  if(stateA != lastA) {
    position += (stateB ? 1 : -1);
    Serial.print("Position: ");
    Serial.println(position);
  }
  lastA = stateA;
}

Reed Switch Operating Characteristics

Glass-enclosed rhodium contacts; 10-50 gauss trigger; 0.2ms close/open; 10^9 operations; -40 to 125°C; infinite MTBF.

Industrial Position Sensing Applications

Door/window security perimeters

Elevator position encoders

Conveyor belt product counting

Program: Arduino Uno Reed Switch - Tank Level Indicator
// Multiple reed switches for continuous level
const int reedPins[] = {2, 3, 4, 5, 6};
int level = 0;

void loop() {
  level = 0;
  for(int i=0; i<5; i++) {
    if(digitalRead(reedPins[i]) == HIGH) {
      level = i + 1;
      break;
    }
  }
  Serial.print("Tank Level: ");
  Serial.print(level * 20);
  Serial.println("%");
}

Production Magnetic Specifications

  • 1-5cm N52 magnet range
  • 10-50 gauss adjustable
  • 0.2ms response time
  • <1μA quiescent current
  • Hermetically sealed contacts

Reliable Deployment Protocol

N52 magnets >10x3mm cylinder. 2-5mm glass reed gap. Avoid ferrous shielding. 1ms software debounce optional. Parallel operation unlimited.