Close Menu
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
Facebook X (Twitter) Instagram
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us
Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
How To Electronics
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
How To Electronics
Home » Vibration Detection with SW-420 Vibration Sensor & Arduino
Arduino Projects

Vibration Detection with SW-420 Vibration Sensor & Arduino

Mamtaz AlamBy Mamtaz AlamUpdated:February 2, 20255 Mins Read
Share Facebook Twitter LinkedIn Telegram Reddit WhatsApp
Vibration Detection with SW-420 Vibration Sensor & Arduino
Share
Facebook Twitter LinkedIn Pinterest Email Reddit Telegram WhatsApp

Overview

In this project, we will make a Vibration Detection System using the SW-420 Vibration Sensor and an Arduino.

Vibration is a common phenomenon in machinery and structures, and while it can be harmless, excessive vibration may indicate impending failures or structural defects. Early detection of unusual vibrations can be critical for maintenance and safety in industrial settings, as well as for security applications where vibrations may indicate tampering or intrusion.

In this post, we’ll show you how to make a system that can detect shakes or trembles using a SW-420 Vibration Detection Sensor and an Arduino. This system will use a light (LED) and a sound (buzzer) to let people or other systems nearby know when it senses any unusual movement.


Bill of Materials

For this tutorial I am using the SunFounder Arduino Starter Kit which has 90+ components.

Here are the list of components I am using from this Kit.

S.N.ComponentsQuantityPurchase Links
1Arduino UNO R4/R3 Board1Amazon | AliExpress
2SW-420 Vibration Sensor1Amazon | AliExpress | SunFounder
3Red LED1Amazon | AliExpress | SunFounder
4Buzzer1Amazon | AliExpress | SunFounder
5Connecting Wires10Amazon | AliExpress | SunFounder
6Type C USB Cable1Amazon | AliExpress
7Breadboard1Amazon | AliExpress | SunFounder



Vibration Sensor Module (SW-420)

The SW-420 vibration sensor is a small module designed to detect vibrations or shocks on surfaces.

SSW-420 Vibration Sensor Module

It’s a versatile device that can be used for a variety of applications, such as sensing if someone knocks on a door, identifying problems in machines, detecting car accidents, or as part of an alarm system. This sensor is compatible with low-voltage systems since it operates on a power supply ranging from 3.3 V to 5 V.

Working Principle of Vibration Sensor

At the heart of the SW-420 vibration sensor module is a SW-420 vibration switch coupled with an LM393 voltage comparator. The vibration switch contains a spring-loaded rod within a tube.

When a vibration or shock occurs, the movement causes the spring to make contact with the rod, thus closing an electrical circuit. The sensor detects these movements and translates them into electrical signals.

The LM393 comparator is a critical component in this setup. It takes the electrical signals from the vibration switch and compares them to a preset threshold voltage, which you can adjust using the onboard potentiometer. When the signal’s amplitude surpasses the threshold, the comparator’s output switches to high (1), indicating a vibration has been detected. If the signal is below the threshold, the output remains low (0), indicating no significant vibration.

Features & Specifications of SW-420 Vibration Sensor

  • Voltage: 3.3-5V DC
  • Current: 15mA
  • Sensor: SW-420 normally closed
  • Indicators: Power and signal LEDs
  • Design: LM393 comparator
  • Compatibility: Easy to use with microcontrollers
  • Installation: Bolt holes for mounting
  • Size & Cost: Compact, affordable, widely available



Pinout of SW-420 Vibration Sensor

The SW-420 module typically has three to four pins:

SW-420 Vibration Sensor Pinout

  1. VCC: Connects to the power supply (3.3 V to 5 V).
  2. GND: Connects to the ground of the power supply.
  3. D0: Digital output pin that goes high when vibration is detected (after the threshold set by the potentiometer is exceeded).
  4. A0: (Not always available) Analog output pin that provides a voltage signal proportional to the vibrations detected.

Vibration Detection with SW-420 Vibration Sensor & Arduino

Now let us interface the SW-420 Vibration Detection Sensor with Arduino, LED and Buzzer.

Circuit Diagram & Connections

Here is a simple circuit diagram for this project.

SW-420 Vibration Sensor Arduino Interfacing

Connect the SW-420 Vibration sensor’s VCC to Arduino’s 5V and GND to Arduino’s GND, and its digital output pin to Arduino’s pin 4.

Vibration Sensor Arduino Connection

The buzzer’s positive lead connects to Arduino’s pin 3, and its negative lead to another GND pin. Lastly, connect the LED’s anode to Arduino’s pin 2 through a 220-ohm resistor, and its cathode directly to Arduino’s GND.



Source Code/Program

The code for Vibration Detection with SW-420 Vibration Sensor & Arduino is very simple and is written in Arduino IDE. You can copy the following code and paste it on your Arduino IDE editor window.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const int sensorPin = 4;
const int ledPin = 2;      // Define the pin for the LED
const int buzzerPin = 3;   // Define the pin for the buzzer
 
void setup()
{
  Serial.begin(9600);          // Start serial communication at 9600 baud rate
  pinMode(sensorPin, INPUT);   // Set the sensorPin as an input pin
  pinMode(ledPin, OUTPUT);     // Set the ledPin as an output pin
  pinMode(buzzerPin, OUTPUT);  // Set the buzzerPin as an output pin
}
 
void loop()
{
  if (digitalRead(sensorPin))                 // Check if there is any vibration detected by the sensor
  {
    Serial.println("Detected vibration...");   // Print "Detected vibration..." if vibration detected
    digitalWrite(ledPin, HIGH);                // Turn on the LED
    tone(buzzerPin, 1000);                     // Play a 1kHz tone on the buzzer
  }
  else
  {
    Serial.println("...");                     // Print "..." otherwise
    digitalWrite(ledPin, LOW);                 // Turn off the LED
    noTone(buzzerPin);                         // Stop playing any tone on the buzzer
  }
 
  // Add a delay to avoid flooding the serial monitor
  delay(100);
}

From the tools menu, Select the Arduino UNO Board and the Arduino COM port. Then click on the upload icon to upload the code.



Testing & Results

When the SW-420 vibration sensor detects movement, it sends a digital HIGH signal to the designated input pin on the Arduino. The programmed code reacts to this signal by executing two functions.

Firstly, it sends a HIGH signal to the LED pin, lighting up the LED. This acts as a visual cue that vibration has been detected. Secondly, it triggers the buzzer connected to another pin to emit a sound, serving as an auditory alert.

Conversely, when no vibration is present, the sensor sends a LOW signal to the Arduino. The code responds by turning off the LED (sending a LOW signal to the LED pin) and silencing the buzzer, indicating a stable environment without any detected vibrations.


Conclusion

Building a vibration detection system using an Arduino and the SW-420 vibration sensor is an excellent project for enthusiasts and those interested in learning about sensors and alert systems. It showcases how straightforward components can be assembled to develop practical and responsive systems. With proper configuration and coding, anyone can create a fundamental vibration detection system that enhances security and offers immediate alerts to potential disturbances or unauthorized access.

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Reddit Telegram WhatsApp
Previous ArticleFire Detection System using Flame Sensor & Arduino
Next Article MyArm 300 Pi Unboxing & Usage – Portable 7-Axis Robotic Arm

Related Posts

DC Energy Meter using Arduino

Build a DC Energy Meter using Arduino – 32V/5A

Updated:August 26, 20252K
Interfacing ADXL375 Accelerometer with Arduino

Interfacing ADXL375 Accelerometer with Arduino (±200g)

Updated:June 28, 2025
PZEM-004T Arduino Energy Meter

DIY AC Energy Meter using PZEM-004T & Arduino

Updated:March 6, 20258K
Interfacing BMI160 Accelerometer & Gyroscope with Arduino

Interfacing BMI160 Accelerometer & Gyroscope with Arduino

Updated:February 2, 20259K
Password Based Door Lock Security System Using Arduino & Keypad

Password Based Door Lock Security System Using Arduino & Keypad

Updated:February 2, 20252436K
Earthquake Detector Alarm with with Accelerometer & Arduino

Earthquake Detector Alarm with Accelerometer & Arduino

Updated:February 2, 2025661K
Add A Comment

CommentsCancel reply

Latest Posts
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

May 31, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

May 10, 2026
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

May 2, 2026
A Guide to Sourcing Obsolete ICs for Vintage Projects

Beyond AliExpress: A Guide to Sourcing Obsolete ICs for Vintage Projects

April 21, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

April 27, 2026
Building a Smart Sensor Node with a BLE Microcontroller

Building a Smart Sensor Node with a BLE Microcontroller

February 26, 2026
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

April 27, 2026
DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

February 1, 2026
Top Posts & Pages
  • Buck Converter: Basics, Working, Design & Application
    Buck Converter: Basics, Working, Design & Application
  • How to use INA226 DC Current Sensor with Arduino
    How to use INA226 DC Current Sensor with Arduino
  • How to use Modbus RTU with ESP32 to read Sensor Data
    How to use Modbus RTU with ESP32 to read Sensor Data
  • How to use INA219 DC Current Sensor Module with Arduino
    How to use INA219 DC Current Sensor Module with Arduino
  • 12V DC to 220V AC Inverter Circuit & PCB
    12V DC to 220V AC Inverter Circuit & PCB
  • Designing of MPPT Solar Charge Controller using Arduino
    Designing of MPPT Solar Charge Controller using Arduino
  • IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
    IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
  • IoT Based Electricity Energy Meter using ESP32 & Blynk
    IoT Based Electricity Energy Meter using ESP32 & Blynk
Categories
  • Arduino Projects (197)
  • Articles (60)
    • Learn Electronics (19)
    • Product Review (15)
    • Tech Articles (28)
  • Electronics Circuits (46)
    • 555 Timer Projects (21)
    • Op-Amp Circuits (7)
    • Power Electronics (13)
  • IoT Projects (204)
    • ESP32 MicroPython (7)
    • ESP32 Projects (81)
    • ESP32-CAM Projects (15)
    • ESP8266 Projects (76)
    • LoRa/LoRaWAN Projects (22)
  • Microcontrollers (38)
    • AMB82-Mini IoT AI Camera (4)
    • BLE Projects (18)
    • STM32 Projects (19)
  • Raspberry Pi (93)
    • Raspberry Pi Pico Projects (57)
    • Raspberry Pi Pico W Projects (12)
    • Raspberry Pi Projects (24)
Follow Us
  • Facebook
  • Twitter
  • Pinterest
  • Instagram
  • YouTube
About Us

“‘How to Electronics’ is a vibrant community for electronics enthusiasts and professionals. We deliver latest insights in areas such as Embedded Systems, Power Electronics, AI, IoT, and Robotics. Our goal is to stimulate innovation and provide practical solutions for students, organizations, and industries. Join us to transform learning into a joyful journey of discovery and innovation.

Copyright © How To Electronics. All rights reserved.
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us

Type above and press Enter to search. Press Esc to cancel.

Ad Blocker Enabled!
Ad Blocker Enabled!
Looks like you're using an ad blocker. Please allow ads on our site. We rely on advertising to help fund our site.