What it is: The SW-420 is a vibration sensor module — a spring-loaded switch that opens and closes when shaken or knocked. It's used for tamper alarms, knock detection, and machine-running indicators.
How it works: At rest the switch is closed and DO reads one level; a vibration jiggles it, toggling DO. The onboard comparator + trimmer set the trigger. This sketch reports "SHAKE" when the digital output goes LOW (the triggered state on most SW-420 boards).
Wiring:
SW-420 DO -> GPIO10 (digital)
SW-420 VCC -> 3V3
SW-420 GND -> GND
OLED VCC=3V3, GND=GND, SDA=GPIO4, SCL=GPIO5
Libraries: only "Adafruit SSD1306" and "Adafruit GFX Library".
On screen / Serial: "STILL" or "SHAKE!". Tap the desk near it and turn the trimmer to set sensitivity.
Gotchas: It's a coarse yes/no vibration switch, not an accelerometer — for measuring vibration magnitude use the ADXL345. The idle/triggered logic can be inverted on some boards; if it reads backwards, flip the comparison in code.