Vibration Sensor with Arduino – How to use SW-420

Learn how to use a Vibration Sensor (SW-420) with Arduino. In this post we’ll go over the basics of the Vibration Sensor, the sensor pins, how to connect to an Arduino UNO, how to program in Arduino, and testing of the sensor.

Vibration Sensor Basics

The Vibration Sensor (SW-420) can be used to detect whether or not vibration is present. The sensor will not provide an analog signal to indicate the intensity of the vibration, instead it will indicate whether or not vibration is present through a digital output. To define what constitutes as a vibration, one must set the sensor sensitivity through a built-in potentiometer (more details provided later).

Sensor Pins and Connection to Arduino

VCC – Connected to Arduino UNO 5V output.
GND – Connected to Arduino GND.
DO – Digital Output

Vibration sensor pins (SW-420)

Click to Enlarge

Vibration sensor connections to Arduino UNO (SW-420)

Click to Enlarge

Sensor Sensitivity Adjustment

This Vibration Sensor has the capability for sensitivity adjustment. To do so, you need to use the potentiometer included in the sensor circuit board. All you have to do is take a small screwdriver and turn the potentiometer to adjust the sensitivity to vibration. Setting towards the middle of the potentiometer range should work for most applications, but make adjustments if needed and test to confirm.

Vibration sensor sensitivity adjustment (SW-420)

Click to Enlarge

Arduino Code

Run Arduino Code – Testing the Vibration Sensor

All you need to do now is run the code that was provided above and open the Serial Monitor. As soon as you do, you will see the output indicating whether or not vibration is being detected by the sensor. If the serial monitor only shows “Sensing vibration” or “Sensing vibration” regardless of what you do, then consider adjusting the sensor sensitivity through the potentiometer.

Click to Enlarge

Components used in this example

*As an Amazon & Ebay Associate I earn from qualifying purchases.

ComponentLink
Arduino UNOhttps://amzn.to/3uYVAMC
https://ebay.us/veZdKX
Vibration Sensor (SW-420)https://amzn.to/32nmvpb
https://ebay.us/qEaORc

Leave a Reply

Your email address will not be published. Required fields are marked *