Same-day dispatch before 2 PM · Free delivery over ₹999 · GST invoices Get the appPrices incl. GST
Geekobot
Snap & SendNEWGeeko AIWhere's myOrder
Log in
Products
  • Projects
    • Component guidesHow parts work, with code you can run
    • Learning pathsFrom your first LED to your first robot
    • Workshops & eventsOnline sessions for makers and classes
    • ElectrolarkFree guided builds, simulator and certificates
    • Students & teachersStudent discount and classroom help
    • CommunityShare builds and ask other makers
    • CalculatorsOhm's law, LED resistor, 555 and 100+ more
    • Circuit builderWire parts and run the circuit, powered by Electrolark
    • Geeko AIAsk what to buy or how to wire it
    • Snap & SendPhotograph a part or list, we find it
    • Part finderAnswer a few questions, get the right part
    • Compatibility checkWill these two parts work together?
    • Compare partsSpecs side by side
    • Business & bulk ordersGST invoices, credit and volume prices
    • Request a quotationSend your list, get a quote
    • Classroom kitsPer-student kits and lab bundles
    • Gift cardsFor students, teams and events
  • Atal Tinkering Lab
BOM to cart
Geekobot

Components, kits and know-how for makers, students, engineers, labs and businesses across India.

Ask Geeko AIOrders, parts and projects, any timeEmail supportReply within 1 working dayGet the Geekobot appAdd it to your home screen, free

Follow us

Shop

  • Boards & SBCs
  • Sensors & Modules
  • IoT & Wireless
  • Drone & FPV
  • 3D Printing
  • Filaments & Resins
  • Motors & Drivers
  • Power & Batteries
  • Semiconductors
  • Passive
  • Displays & LEDs
  • Switches & Relays
  • Wires & Cables
  • Prototyping
  • Tools & Test
  • Robotics
  • STEM Kits
  • Atal Tinkering Lab
  • Mechanical Parts
  • Audio

Orders

  • Track your order
  • Help & support
  • Shipping and delivery
  • Refunds and cancellation
  • Contact us

Learn

  • Projects
  • Geeko AI project assistant
  • Learning paths
  • Guides
  • Calculators
  • Electrolark: free guided builds

Part tools

  • Part finder
  • Compare parts
  • Will it work with my board?

Institutions

  • Classroom kits
  • Atal Tinkering Lab
  • Students & teachers
  • Workshops & Events

Business

  • Business & education
  • Request a quotation
  • BOM bulk upload
  • Quick order by SKU

Company

  • About Geekobot
  • Community
  • Gift cards
  • Terms & conditions
  • Privacy policy
  • Product directory
  • Sitemap

© 2026 Geekobot, a trade name of OLatus Systems Private Limited. All rights reserved.

20, 1st Floor, Neeladri Complex, 10th Cross, Sampige Rd, 2nd Main, Malleshwaram, Bengaluru, Karnataka 560003 · GSTIN 29AACCO0462F1ZM

+91 91810 15607 · connect@geekobot.in · Monday to Saturday, 10 AM to 2 PM IST

UPI · CARDS · NETBANKING · GST INVOICES

ShopProjectsGeeko AIGuides
Compare 0 parts →
Log in

Shop by category

Shop all components
  • Boards & SBCs1,910 products
    • Alternative Single Board Computers
    • Arduino Ecosystem
    • FPGA & Logic Boards
    • Microcontroller & Wireless Boards
    View all
  • Sensors & Modules4,701 products
    • Biomedical & Heart Rate
    • Current, Voltage & Power
    • Force, Weight & Pressure
    • Gas, Weather & Environmental
    View all
  • IoT & Wireless2,314 products
    • RF Modules
    • RFID & NFC
    • Antennas & RF Accessories
    • Cameras & Smart Vision
    View all
  • Drone & FPV3,558 products
    • Flight Control & Navigation
    • FPV Video & Optics
    • Frames & Structural Parts
    • Motors & Propulsion
    View all
  • 3D Printing2,204 products
    • 3D Printers
    • 3D Scanners & Digitizers
    • Laser Engravers & Cutters
    • Material Management & Upgrades
    View all
  • Filaments & Resins1,472 products
    • Filaments
    • Photopolymer Resins
    View all
  • Motors & Drivers463 products
    • BLDC Motor Drivers
    • DC & Geared Motors
    • DC Motor Drivers
    • Linear Actuators & Solenoids
    View all
  • Power & Batteries557 products
    • Battery Holders & Connectors
    • Breadboard Power
    • Chargers & BMS
    • DC-DC Converters
    View all
  • Semiconductors295 products
    • Diodes & Rectifiers
    • Interface & RF Encoder ICs
    • Logic ICs (74xx)
    • Logic ICs (CD4000)
    View all
  • Passive67 products
    • Capacitors
    • Circuit Protection
    • Crystals & Oscillators
    • Inductors
    View all
  • Displays & LEDs572 products
    • 7-Segment & Dot Matrix
    • Addressable LEDs
    • Character LCDs
    • Graphic LCDs
    View all
  • Switches & Relays184 products
    • Keypads & Touch
    • Push Buttons & Tactile
    • Relay Modules
    • Relays
    View all
  • Wires & Cables233 products
    • Board-to-Wire Connectors
    • Crimp & Splice
    • Headers & Dupont
    • Heat Shrink & Sleeving
    View all
  • Prototyping101 products
    • Breadboards
    • Interface Modules
    • PCBs & Perfboards
    View all
  • Tools & Test717 products
    • Bench Power Supplies
    • Hand Tools
    • Measuring Tools
    • Meters & Testers
    View all
  • Robotics180 products
    • Humanoid & Legged Robots
    • Robot Chassis & Platforms
    • Robotic Arms & Grippers
    • Wheels & Casters
    View all
  • STEM Kits268 products
    • Arduino Learning Kits
    • Coding & IoT Kits
    • Early Coding (Ages 3-8)
    • Invention Kits
    View all
  • Atal Tinkering Lab196 products
    • Package 1: Electronics, Robotics, IoT and Sensors
    • Package 2: Rapid Prototyping Tools
    • Package 3: Mechanical, Electrical and Measurement Tools
    • Package 4: Power Supply, Accessories and Safety Equipment
    View all
  • Mechanical Parts212 products
    • Bearings
    • Brackets & Mounts
    • Couplers
    • Fasteners & Standoffs
    View all
  • Audio109 products
    • Amplifier Modules
    • Buzzers & Sirens
    • Speakers
    View all
  1. Home
  2. ›Guides
  3. ›Sensors
  4. ›SW-420 vibration sensor

Component guide · Beginner · 3 min read

SW-420 vibration sensor

Pinout, Wiring and Code

By Geekobot Learning Team · Updated 29 Oct 2026

I'm using
Wiring, code and the Run it panels follow your board.
On this page
Short answerWhat the SW-420 vibration sensor isSW-420 vibration sensor pinoutWiring the SW-420 vibration sensorExample codeSetup and tuningWhat you needAlternatives and when to choose themCommon mistakesFAQsParts and next steps
Short answer

The SW-420 module detects vibration and knocks using a normally-closed spring switch and an LM393 comparator. When the board shakes, the switch opens briefly and the digital output changes; the trimmer sets how much shaking is needed. It is a simple on/off sensor for alarms and machine-running detection, not a vibration meter.

Key specs at a glance

Sensor
SW-420 normally-closed vibration switch
Output
Digital DO (LM393 comparator), LED indicator
Sensitivity
Adjustable with the trimmer
Supply
3.3 to 5 V
Signal
Short pulses while vibration lasts
Size
About 32 x 14 mm with mounting hole

Models in this guide

These are alternatives. Pick the one that fits your project; you only need one.

  • Option 1SW-420 Vibration Sensor Module Alarm for Arduino – Digital Output₹42
  • Option 2Seeed Studio SW-420 Grove Vibration Sensor Module – Digital Output₹499
01

What the SW-420 vibration sensor is

Inside the SW-420 is a tiny spring around a metal pin. At rest they touch; vibration makes them separate for a moment. The comparator turns those brief openings into clean digital pulses.

More pulses per second means stronger or longer shaking, so counting pulses gives a rough level. For measured vibration in g, use an accelerometer.

02

SW-420 vibration sensor pinout

The pins on the SW-420 vibration sensor and what each one does.

PinFunction
VCC3.3 to 5 V
GNDGround
DODigital output: changes on vibration
PinFunction
VCC
3.3 to 5 V
GND
Ground
DO
Digital output: changes on vibration
03

Wiring the SW-420 vibration sensor

Mount the module firmly to the object you want to monitor; a loose board picks up its own wobble.

SW-420 vibration sensor pinArduino UnoESP32
VCC5V3V3
GNDGNDGND
DOD2 (interrupt)GPIO 27
VCC
Arduino Uno:
5V
ESP32:
3V3
GND
Arduino Uno:
GND
ESP32:
GND
DO
Arduino Uno:
D2 (interrupt)
ESP32:
GPIO 27
04

Example code

Counting pulses over a second filters out single knocks. Tune the threshold (20 here) for your machine.

Count vibration pulses per second · Arduino C++Verify & upload in Electrolark
const int DO_PIN = 2;
volatile unsigned long pulses = 0;

void onPulse() { pulses++; }

void setup() {
  Serial.begin(9600);
  pinMode(DO_PIN, INPUT);
  attachInterrupt(digitalPinToInterrupt(DO_PIN), onPulse, CHANGE);
}

void loop() {
  noInterrupts(); unsigned long n = pulses; pulses = 0; interrupts();
  Serial.print(n); Serial.println(n > 20 ? "  vibration!" : "");
  delay(1000);
}
05

Setup and tuning

Sensitivity

turn the trimmer until the LED stays steady at rest, then back it off slightly.

Machine monitor

a washing machine or pump that stops vibrating for several minutes can trigger a 'finished' message on an ESP32.

Anti-theft

combine with a buzzer for a bike or box alarm.

Orientation

the switch responds best to motion perpendicular to the spring.

06

What you need

Shop this list4 of 5 found in our store · ₹617

  • SW-420 vibration sensor module: the common moduleSW-420 Vibration Sensor Module Alarm for Arduino – Digital Output₹42
  • Seeed Grove SW-420 vibration sensor: Grove connectorSeeed Studio SW-420 Grove Vibration Sensor Module – Digital Output₹499
  • Uno R3 development board: the controller used in the wiring tableFind this part
  • Buzzer module 3.3-5 V: for an audible alarmBuzzer Module 3.3–5V₹27
  • Dupont jumper wires: for the connectionsDupont Jumper Wires (40 pcs)₹49Closest match, check the specs
07

Alternatives and when to choose them

  • ✓Vibration and tilt sensors: ball switches, piezo and more.
  • ✓Piezo sensors: knock detection with an analog signal.
  • ✓Accelerometers: measure vibration amplitude and frequency.
08

Common mistakes to avoid

  • !Expecting a vibration strength in g.
  • !Leaving the module loose so it triggers on its own.
  • !Polling the pin slowly and missing short pulses.
  • !Setting the trimmer so high that the output is always active.
09

Frequently asked questions

How does the SW-420 work?

A spring touches a pin at rest; vibration separates them briefly and the comparator outputs a pulse.

Is DO HIGH or LOW on vibration?

It depends on the board; most go HIGH while vibrating. Check with the LED and Serial Monitor.

Can it measure earthquake strength?

No. It only detects vibration. Use an accelerometer for measurements.

Does it work with ESP32?

Yes, at 3.3 V.

How do I adjust sensitivity?

Turn the blue trimmer potentiometer.

Can it detect a door knock?

Yes, when mounted firmly on the door.

Parts for this guide

  • SW-420 Vibration Sensor Module Alarm for Arduino – Digital Output
    ₹42View
  • Seeed Studio SW-420 Grove Vibration Sensor Module – Digital Output
    ₹499View
  • Uno R3 Development Board (No Cable)
    ₹359View
  • Buzzer Module 3.3–5V
    ₹27View
  • Dupont Jumper Wires (40 pcs)
    ₹49View
Shop Tilt, Inclinometer & Vibration Sensors

Projects that use it

Put this into practice: 20 step-by-step builds in our project library use parts from this guide.

Beginner · 45 minutesVibration and tamper alarmView projectIntermediate · 2–3 hoursThree-zone security alarm on an Arduino MegaView projectBeginner · 45 minutesWhich surface vibrates most?View project
Browse all 20 projects

Keep learning

Component guideBeginnerVibration, Shock and Tilt Sensors (SW-420, SW-520D)Vibration and tilt sensors are simple switches that close or open when shaken or tilted.3 min read · SensorsComponent guideIntermediatePiezo Sensors and DiscsA piezo sensor creates a voltage when it is bent, knocked or vibrated.3 min read · SensorsComparisonIntermediateAccelerometersAn accelerometer measures acceleration along three axes, which lets you detect tilt, taps, free fall and vibration.3 min read · SensorsComparisonBeginnerActive vs Passive BuzzersAn active buzzer beeps at one fixed pitch as soon as you apply DC, so a digital pin can switch it on and off.3 min read · Audio

Sources

  • SW-420 vibration switch data sheet
  • LM393 dual comparator datasheet (Texas Instruments)

Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.

On this page
Short answerWhat the SW-420 vibration sensor isSW-420 vibration sensor pinoutWiring the SW-420 vibration sensorExample codeSetup and tuningWhat you needAlternatives and when to choose themCommon mistakesFAQsParts and next steps
Need a hand?Ask Geeko AI which part fits your project, or talk to the Geekobot team.Ask Geeko AIHelp & support

Parts for this guide2 items · ₹69

SW-420 Vibration Sensor Module Alarm for Arduino – Digital Output · Buzzer Module 3.3–5V

Run itChange the inputs and watch the output
Serial monitor9600 baud
0

A simulation of the sketch above, so you know what to expect. Real readings vary with your parts and wiring.

Ask the Community

Ask a question