SW 420 vibration sensor with Arduino | Step by step instructions

SW 420 vibration sensor with Arduino

SW 420 vibration sensor with Arduino

Hello, welcome back. Today we are going to talk about the SW-420 Vibration sensor. Also, this tutorial explains how to work this vibration sensor and how to connect it to an Arduino board. We can mainly use this sensor to detect vibrations. Also, this sensor can be used for transporting goods unsuitable for vibration and for equipment damaged under vibration conditions. That is, in those cases, vibrations can be detected and action can be taken. The knowledge in this tutorial can also be used for your vibration detection projects.

How does the SW-420 vibration sensor work?

This vibration sensor module mainly includes a sensor called the SW-420. This sensor is activated by opening and closing the electrical contact. In the absence of vibrations, this electrical contact is in a closed state. Also, when there is a vibration, the electrical contact opens and the resistance level rises. Then a pulse is generated. This pulse is converted into a digital signal using the LM393 voltage comparator. That is, we can get digital signals through this sensor. Also, the sensitivity of this digital signal can be changed by using the 10k potentiometer included here.

PIN structure of this sensorsw 420 vibration sensor working

OK, now we will learn how to connect this sensor to Arduino step by step. To do this, the necessary components are listed below.

Step 1

Firstly, identify these components.

Arduino Nano board

Vibration sensorsw 420 vibration sensor working

LED bulb

180-ohm resistor

Breadboard

Jumper wires

Step 2

Secondly, connect these components, To do this, use the circuit diagram below.SW 420 vibration sensor with Arduino circuit diagram

Step 3

Thirdly, let’s create the program for this project. It is as follows.

/*Vibration sensor tutorial.
created by the SriTu Tech team.
Read the code below and use it for any of your creation.
https://srituhobby.com
*/

#define LED 3
#define Sensor 2
void setup() {
Serial.begin(9600);
pinMode(Sensor, INPUT);
pinMode(LED, OUTPUT);
}
void loop() {
bool value = digitalRead(Sensor);
if (value == 1) {
digitalWrite(LED,HIGH);
}else if(value == 0){
digitalWrite(LED,LOW);
}
}


Code explanation

First, the LED and sensor PINs are defined.

#define LED 3
#define Sensor 2

In the setup function, the sensor pin set as input, and the LED pin set as output. Also, the serial monitor is started.

void setup() {
Serial.begin(9600);
pinMode(Sensor, INPUT);
pinMode(LED, OUTPUT);
}

In the loop function, the sensor values are taken and these values are put into a Boolean variable. Also, these values are checked using the IF condition. If the value is 1, the LED is turned ON. Otherwise, LED is turned OFF.

void loop() {
bool value = digitalRead(Sensor);
if (value == 1) {
digitalWrite(LED,HIGH);
}else if(value == 0){
digitalWrite(LED,LOW);
}

Step 4

Lastly, select board and port, Afterward, upload this code to the Arduino board.SW 420 vibration sensor with Arduino code upload

SW 420 vibration sensor with Arduino code upload

SW 420 vibration sensor with Arduino code upload

SW 420 vibration sensor with Arduino code upload

OK, study this tutorial carefully. The full video guide is given below. So, we will meet in the next tutorial.

Related Posts

Leave a Reply

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