Many Applications can created by measuring Vibration level, but sensing vibration accurately is a difficult job. This article describes about vibration sensor SW-420 and Arduino interface then it may help you to design effort less vibration measurement.




Arduino IDE (version 1.6.4+)

About Vibration Sensor Module

Vibration Sensor Module comes with SW-420 vibration sensor, integrated with adjustable sensitivity via on board potentiometer. There are also LED indicators for power and the digital output status on board. It has a simple and straight forward 3-pin interface, VCC, GND and the DO (digital output). It supports 3.3V or 5V power.

This vibration sensor module is compatible with any microcontroller that has a digital input, so of course any popular microcontroller such and PIC, Arduino and Raspberry Pi are compatible. A direct interface is essential to using this sensor.

The DO pin will be LOW when there is no vibration, and indicator LED will lit up.

Module Features:


This Vibration Sensor can be used to detect vibration from any angle. There is an on-board potentiometer to adjust the threshold of vibration. It outputs logic HIGH when this module not triggered while logic Low when triggered.

Application Idea

•Automobie alarm.

•Movement detection.

•Vibration detecting Applications Features



Connect Vcc pin of sensor board to 5V pin of Arduino board, connect Gnd pin to Gnd pin of Arduino, Connect DO output signal pin of sensor board to Arduino digital pin D3. Do some calibration and adjust the sensitivity threshold, then upload the following sketch to Arduino board.

Vibration Sensor Module OSOYOO UNO

Arduino Code for Logic State Output

In this project, we will connect Arduino with Vibration sensor and LED. When no vibration is detected, Vibration sensor output is 0 (low voltage),otherwise its output is 1(high voltage)。 If Arduino get 0 (no vibration) from vibration sensor it will turn on green LED and turn off Red LED. If Arduino get 1 from vibration sensor, it will turn on Red LED and turn off green LED.(Please choose the correct board type and correct port com for your Arduino IDE)

int vib_pin=3;
int led_pin=13;
void setup() {

void loop() {
  int val;

Arduino Code for Value Reading 

Arduino Code for Value Reading and serial printing Vibration value, this code turns ON the onboard LED when measurement goes greater than 1000, you can adjust this threshold to your need.

int LED_Pin = 13;
int vibr_Pin =3;

void setup(){
  pinMode(LED_Pin, OUTPUT);
  pinMode(vibr_Pin, INPUT); //set vibr_Pin input for measurment
  Serial.begin(9600); //init serial 9600
 // Serial.println("----------------------Vibration demo------------------------");
void loop(){
  long measurement =TP_init();
 // Serial.print("measurment = ");
  if (measurement > 1000){
    digitalWrite(LED_Pin, HIGH);
    digitalWrite(LED_Pin, LOW); 

long TP_init(){
  long measurement=pulseIn (vibr_Pin, HIGH);  //wait for the pin to get HIGH and returns measurement
  return measurement;

Finally, you should open the Arduino IDE serial monitor at a 9600 baud rate and you’ll see: