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. ›Vibration, Shock and Tilt Sensors (SW-420, SW-520D)

Component guide · Beginner · 3 min read

Vibration, Shock and Tilt Sensors (SW-420, SW-520D)

By Geekobot Learning Team · Updated 24 Oct 2026

I'm using
Wiring, code and the Run it panels follow your board.
On this page
Short answerTypes and how they workWiring and codeWhen to use an accelerometer insteadCommon mistakesFAQsParts and next steps
Short answer

Vibration and tilt sensors are simple switches that close or open when shaken or tilted. The SW-420 module uses a spring contact and a comparator with a sensitivity pot. The SW-520D tilt switch has a metal ball that rolls to connect two pins. Piezo discs generate a voltage when flexed or knocked. They are cheap and easy, but for real angles or vibration levels use an accelerometer.

Key specs at a glance

SW-420 module
Spring switch, LM393 comparator, digital output, sensitivity pot
SW-520D
Ball tilt switch: closed when upright, opens when tilted past roughly 45°
Piezo modules
Analog or digital output from a piezo film or disc
Supply
3.3 to 5 V for modules
Output
Short pulses, so use interrupts or fast polling
Better option
MPU6050 or ADXL345 accelerometer for angle or vibration level
01

Types and how they work

Spring vibration switch (SW-420, SW-18010P)

a spring around a pin touches it briefly when shaken. The module's comparator turns those contacts into a digital signal, and the potentiometer sets how much shaking counts.

Ball tilt switch (SW-520D)

a metal ball connects two contacts when upright and rolls away when tilted. It bounces, so debounce it.

Piezo sensors

a piezo element produces a voltage when it is flexed or knocked. Great for knock detection and drum pads; add a 1 MΩ resistor across it to bleed the charge, and a zener or the module's circuit to limit spikes.

02

Wiring and code

Connect VCC, GND and DO to a digital pin. Vibration pulses can be only a few milliseconds long, so use an interrupt or poll quickly and count pulses over a window.

Count vibration pulses per second (Arduino Uno) · Arduino C++Verify & upload in Electrolark
const byte PIN = 2;            // interrupt-capable pin
volatile unsigned int hits = 0;

void onHit() { hits++; }

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

void loop() {
  delay(1000);
  noInterrupts(); unsigned int n = hits; hits = 0; interrupts();
  Serial.println(n);           // higher = more vibration
  if (n > 20) Serial.println("Shaking!");
}
03

When to use an accelerometer instead

Switch sensors answer "did it move?" They cannot tell you the tilt angle, the direction or how strong the vibration is. For a self-balancing robot, a spirit level, machine health monitoring or fall detection, use an MPU6050 or similar accelerometer, which gives real numbers on three axes.

04

Common mistakes to avoid

  • !Polling slowly and missing short vibration pulses.
  • !Not debouncing a ball tilt switch.
  • !Connecting a bare piezo straight to an input without a bleed resistor or clamp.
  • !Expecting an angle reading from a tilt switch.
  • !Setting the SW-420 pot so sensitive it triggers constantly.
05

Frequently asked questions

How do I adjust the SW-420 sensitivity?

Turn the blue potentiometer until the LED stays off at rest and flickers when tapped.

Is a tilt switch the same as an accelerometer?

No. A tilt switch is on or off; an accelerometer measures angle and acceleration.

Can I detect a knock on a door?

Yes. A piezo sensor taped to the door with an analog reading and a threshold works well.

Why does my vibration sensor trigger randomly?

It is too sensitive or picking up desk vibration. Turn down the pot and mount it firmly.

Do tilt switches contain mercury?

Old ones did. Modern SW-520D types use a metal ball and are mercury-free.

Parts for this guide

  • Seeed Studio SW-420 Grove Vibration Sensor Module – Digital Output
    ₹499View
  • 801S Vibration Shock Sensor Module – LM393 Comparator, Adjustable Sensitivity
    ₹170View
  • SW-18015P Vibration Switch Sensor Module for Arduino – 12V DC
    ₹24View
  • SW-420 Vibration Sensor Module Alarm for Arduino – Digital Output
    ₹42View
Shop Motion & Position Sensors

Terms in this guide

ComparatorA circuit that compares two voltages and outputs HIGH or LOW depending on which is larger. Sensor modules use one (often an LM393) to produce their digital output.DebounceFiltering the rapid on-off bouncing of a mechanical switch so one press counts once.InterruptA hardware signal that makes the microcontroller pause its program and run a short function immediately, for example when a button pin changes.PiezoA ceramic element that bends when voltage is applied (and makes a voltage when bent), used in passive buzzers and vibration sensors.AccelerometerA sensor that measures acceleration, including gravity, along one or more axes; used to detect tilt, vibration and movement.

Keep learning

Component guideIntermediateMPU6050 Accelerometer and GyroscopeThe MPU6050 is a 6-axis motion sensor that combines a 3-axis accelerometer and a 3-axis gyroscope on one chip and talks over I2C at address 0x68.3 min read · SensorsComponent guideIntermediateComparatorsA comparator compares two voltages and switches its output depending on which is higher.3 min read · Semiconductors & ICsComparisonBeginnerActive 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 · AudioHow-toBeginnerPush Buttons with ArduinoWire a push button between a digital pin and ground, set the pin to INPUT_PULLUP, and the pin reads LOW while pressed.3 min read · Switches, Relays & InputComponent guideBeginnerPIR Motion Sensor (HC-SR501)A PIR (passive infrared) sensor detects movement of warm bodies by sensing changes in infrared heat across its field of view.3 min read · Sensors

Sources

  • SW-420 and SW-520D switch datasheets
  • TI LM393 datasheet
  • TE Connectivity piezo film sensor technical manual

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

On this page
Short answerTypes and how they workWiring and codeWhen to use an accelerometer insteadCommon 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 guide4 items · ₹735

Seeed Studio SW-420 Grove Vibration Sensor Module – Digital Output · 801S Vibration Shock Sensor Module – LM393 Comparator, Adjustable Sensitivity · SW-18015P Vibration Switch Sensor Module for Arduino – 12V DC · SW-420 Vibration Sensor Module Alarm for Arduino – Digital Output

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

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