
The vibration sensor for Arduino or "Vibration Sensor (SW-420 v1.1)" is assembled on the basis of a spring-type vibration sensor SW-420 and a comparator LM393, this module is from the Grove System series. The Grove module was provided by Seeed Studio and can be purchased here: Grove - Vibration Sensor (SW420) - Seeed Studio .
The principle of operation of the sensor is quite simple. At rest, the SW-420 sensor is in an open state and no current flows through it, but at the output (SIG) we have a logical unit (Vcc). Under external influence (push, impact, etc.), the spring swings and shortly closes the contacts, and at the output of the SIG pin we get a logical zero (GND). A potentiometer is installed on the board and it is possible to set the response threshold. The vibration sensor response does not depend on its location in space.
The LM393 comparator, which has two analog inputs and one digital output, compares the electrical signals received from the SW-420 and the potentiometer with each other and outputs a digital signal indicating an increase in one input signal over the other.
Application options
The most relevant application of vibration sensors can be implemented in the field of burglar alarms for various purposes. Due to the high level of sensitivity, such devices can respond to vibrations of a wide range of intensities, capturing vibrations in all planes. Thanks to the simple connection method, vibration sensors are used to implement a wide variety of projects:
- Security systems;
- Alarms;
- Electronic locks;
- Motion detectors;
- Anti-theft systems;
- Seismic stations;
- Kids toys;
- Appliances;
- Sports Equipment.
Module pinout
The vibration sensor module has four outputs:
Conclusion | Description | |
---|---|---|
one | GND | Land |
2 | VDD | Nutrition |
3 | NC | Not used |
4 | SIG | Signal output |
Vibration Sensor SW-420 Specifications
- Working voltage : 3.3 - 5 V;
- Used sensor : SW-420;
- Comparator used : LM393;
- Sensitivity : adjustable;
- Interface : digital;
- Weight : 10g;
- Dimensions : 40mm x 20mm x 7mm.
Grove module schematic diagram
Implementation example
To work with the module, you do not need to install additional libraries. The circuit is assembled according to the figure (see below). Connect the SIG (or DO) digital pin to digital pin 2 of the Arduino. In the presence of vibrations, the signal value increases many times and when the threshold value is reached, which is set by the potentiometer, a logical zero is applied to the SIG (or DO) pin. The value is read by the function digitalRead()
in a cycle loop()
, after which, by calling the function digitalWrite()
, the LED built into the board lights up if the read value is equal to zero.
Wiring diagram for vibration sensor to arduino
Arduino | Grove - Vibration Module | Wire color |
---|---|---|
GND | GND | Black |
5V | VCC | Red |
NC | NC | White |
D2 | SIG / DO | Yellow |
Example sketch
# define PIN_LED 13
/ *
Pin to which the vibration sensor is connected
* /
# define PIN_SENSOR 2
int alarm;
void setup () {
alarm = 0 ;
pinMode (PIN_LED, OUTPUT);
pinMode (PIN_SENSOR, INPUT);
Serial.begin ( 9600 );
}
void loop () {
/ *
Reading the value from the sensor
* /
int val = digitalRead (PIN_SENSOR);
if (val == LOW) {
/ *
Sensor triggered - turn on the LED
* /
digitalWrite (PIN_LED, HIGH);
Serial.print (alarm);
Serial.println ( "Alarm!" );
alarm ++;
} else {
digitalWrite (PIN_LED, LOW);
}
}
Social Plugin