How to use a Vibration Sensor with Arduino
How to use a Vibration Sensor with Arduino
INTRODUCTION
A vibration sensor is a transducer that detects vibrations and small movements (to and fro motion).
APPLICATIONS
The vibration sensor can be used to detect abnormal vibration in a mechanical system, automation working robots and driverless vehicles.
WIRING DIAGRAM
GND – GND
VCC - 5V
OUT – Digital Pin 10
CODE
int Led = 13 ;// define LED Interface int Shock = 10; // define the vibration sensor interface int val; // define numeric variables val void setup () { pinMode (Led, OUTPUT) ; // define LED as output interface pinMode (Shock, INPUT) ; // output interface defines vibration sensor } void loop () { val = digitalRead (Shock) ; // read digital interface is assigned a value of 3 val if (val == HIGH) // When the shock sensor detects a signal, LED flashes { digitalWrite (Led, LOW); } else { digitalWrite (Led, HIGH); } }
END RESULT
Try to touch/vibrate the sensor with your figure and the built-in LED (at Pin 13 on the Arduino-compatible board) will glow when a vibration is detected.
ADDITIONAL RESOURCES
https://www.instructables.com/id/How-to-use-a-vibration-sensor-shake-switch-Arduino/