Arduino - SW-420 Vibration Sensor
Shocks, bumps, and shaking are easy for us to feel but hard for a plain Arduino to notice on its own. The SW-420 vibration sensor module fills that gap: it watches for mechanical disturbance and reports it as a simple digital signal, which is handy for security alarms, impact loggers, or any project that needs to react when something gets bumped or shaken.
In this tutorial, we are going to learn:
- How to wire a SW-420 vibration sensor module to Arduino
- How to program Arduino to detect vibration or shock with the SW-420 module

Once the basic sketch is running, you can extend it to sound a buzzer, flash an LED, or send an alert whenever vibration is picked up.
Hardware Required
Or you can buy the following kits:
| 1 | × | DIYables STEM V3 Starter Kit (Arduino included) | |
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some links direct to products from our own brand, DIYables .
About SW-420 Vibration Sensor
The SW-420 vibration sensor module reacts to shaking, bumping, or shock in its surroundings. Inside the module sits a small spring-based switch positioned close to a metal contact; when vibration disturbs the spring, an onboard LM393 comparator turns that mechanical disturbance into a clean digital signal, so Arduino only has to read a HIGH or LOW pin instead of dealing with noisy analog readings.
The SW-420 Vibration Sensor Pinout
The SW-420 module breaks out three pins:
- VCC pin: needs to be connected to VCC (3.3V to 5V)
- GND pin: needs to be connected to GND (0V)
- DO pin: is an output pin: LOW while everything is still, HIGH the moment vibration or shock is detected. This pin needs to be connected to Arduino's input pin.

Two LEDs sit on the board:
- One LED indicator for power
- One LED indicator that lights up whenever the DO pin goes HIGH (vibration detected)
A small onboard potentiometer lets you dial the sensitivity up or down, so light taps or only stronger shocks can trigger the output, depending on how you turn it.
How It Works
- While the module sits still, the spring switch stays open, the comparator keeps its output LOW, and the trigger LED stays off.
- Once vibration or shock disturbs the spring, the switch closes momentarily, the comparator drives the output HIGH, and the trigger LED lights up.
Wiring Diagram

This image is created using Fritzing. Click to enlarge image
How To Program For SW-420 Vibration Sensor
- Sets the Arduino pin to digital input mode with pinMode() function. For example, pin 5
- Gets the current logic level of that pin with digitalRead() function.
Arduino Code - Detecting vibration
Quick Steps
- Copy the above code and open with Arduino IDE
- Click Upload button on Arduino IDE to upload code to Arduino
- Tap or shake the SW-420 module gently
- See the result on Serial Monitor.
From here, you could trigger a buzzer, light up an LED, or push a notification whenever vibration shows up. You can find more information and step-by-step instructions in the tutorials provided at the end of this tutorial.
Troubleshooting
If the SW-420 vibration sensor is not working properly, try the following steps:
- Adjust the sensitivity: Turn the onboard potentiometer to make the module more or less sensitive; if it never triggers, try turning it the other way.
- Isolate the module: Nearby machinery, fans, or footsteps can shake the surface it's mounted on and cause false triggers, so mount it away from unrelated vibration sources.
- Check the wiring: Make sure the VCC, GND, and DO pins are connected correctly.
- Check the power supply: Ensure that the power supply is stable for consistent readings.
Video Tutorial
We are considering to make the video tutorials. If you think the video tutorials are essential, please subscribe to our YouTube channel to give us motivation for making the videos.