Overview

The SW-420 is a popular vibration and shock detection sensor module included in SunFounder, Elegoo, and generic Arduino sensor kits. Built around an SW-420 metallic spring roller-ball vibration switch capsule, an LM393 differential comparator IC, and a multi-turn sensitivity potentiometer, it detects mechanical shocks, shaking, knocking, and seismic movement.

Under non-vibrating stationary conditions, the internal contact spring remains closed (Normally Closed / NC state), causing the module digital output (DO) to sit Low (0V). When physical vibration or shock occurs, internal contacts momentarily bounce open, triggering DO to pulse High (VCCV_{CC}).

Quick reference

Operating voltage (VCC)3.3 V to 5.5 V DC (5.0 V nominal)
Switch elementSW-420 Normally Closed (NC) Vibration Switch
Comparator ICLM393 voltage comparator chip
Quiescent Output (DO)Low (0V) when stationary / High (VCCV_{CC}) when vibrating
IndicatorsPower LED (red) + Vibration Trigger LED (green)
Sensitivity adjustmentMulti-turn trimmer potentiometer on PCB
Operating current15 mA15\text{ mA} typical

Pinout

Standard 3-pin 0.1" (2.54 mm) module header:

text
        ┌──────────────────────┐
        │  [SW-420 Cylinder]   │
        └─┬───────┬──────────┬─┘
         VCC     GND        DO
          1       2          3
PinNameTypeDescription
1VCC / +PowerSupply power input (+3.3 V to +5.0 V DC)
2GND / -PowerGround reference (0 V)
3DO / SDigital OutputLM393 digital output (Low = Stationary, High = Vibrating)

Specifications

ParameterSymbolMinTypMaxUnitConditions
Supply VoltageVCCV_{CC}3.35.05.5VDC
Active Supply CurrentICCI_{CC}1520mAVCC=5.0VV_{CC} = 5.0\text{V}
Switch Resistance (Closed)RclosedR_{closed}0.15.0ΩStationary state
Switch Resistance (Open)RopenR_{open}10Momentary shock bounce
Output Drive CurrentIsinkI_{sink}1520mALM393 output sink/source
Response Timetrespt_{resp}25msShock pulse bounce

Operating Principle & Signal Behavior

  • Stationary State: The internal conductive spring rests against the metallic barrel casing, shorting the circuit. The LM393 output pin (DO) stays Low (0V), and the green onboard LED lights up.
  • Vibration / Impact State: Physical shaking causes the internal spring to vibrate and break electrical contact momentarily. The circuit opens, pulling DO High (VCCV_{CC}) and extinguishing the green LED.
text
 Stationary:  [ DO = LOW (0V) ]  ---> Green LED ON
 Vibrating:   [ DO = HIGH (5V) ] ---> Green LED OFF

Wiring

SW-420 PinArduino UnoESP32Notes
VCC (+)5V / 3.3V3.3VPower rail
GND (-)GNDGNDSystem ground
DO (S)Digital D2 (INT0)GPIO 4Interrupt-driven shock trigger

Example (Arduino Intrusion / Theft Alarm)

cpp
const int vibrationPin = 2; // Connected to DO
const int buzzerPin = 13;

void setup() {
  Serial.begin(9600);
  pinMode(vibrationPin, INPUT);
  pinMode(buzzerPin, OUTPUT);
  Serial.println("SW-420 Vibration Alarm Active");
}

void loop() {
  int val = digitalRead(vibrationPin);

  // HIGH state indicates mechanical vibration/shock contact bounce
  if (val == HIGH) {
    digitalWrite(buzzerPin, HIGH);
    Serial.println("WARNING: VIBRATION DETECTED!");
    delay(500); // Alarm duration
    digitalWrite(buzzerPin, LOW);
  }
}

Common mistakes

  • Polling instead of using hardware interrupts: Mechanical contact bounce pulses last only a few milliseconds (210 ms2\text{--}10\text{ ms}). Simple loop() delays will miss short vibration shocks. Attach an external hardware interrupt (attachInterrupt(digitalPinToInterrupt(2), ISR, RISING)).
  • Mis-adjusting sensitivity potentiometer: Turning the potentiometer too far causes DO to latch permanently High or Low. Adjust until the green LED is ON while motionless.

Notes

  • SW-420 vs ADXL345 vs SW-520D: SW-420 is a simple 1-bit binary vibration switch; ADXL345 is a 3-axis accelerometer measuring numeric g-force; SW-520D is a tilt ball switch.

Assets & downloads