584
Description
This module is digital shock sensor. It will output a high level signal when it detects a shock event. This is also called the vibration sensor module
Specs
Parts Required
Arduino UNO (or equivalent)
KY002 Shock Sensor Module
USB cable
Connections
Pin – = GND, connect to GND
Pin (middle pin) +5 v, connect to +5v
Pin S signal, connect to Arduino pin 3 (or your own choice but code would need updated below)
Code
A simple example the
[codesyntax lang=”cpp”]
int LedPin = 13 ;
int ShockPin = 3;
int val; // define numeric variables val
void setup ()
{
pinMode (LedPin, OUTPUT) ;
pinMode (ShockPin, INPUT) ;
}
void loop ()
{
val = digitalRead (ShockPin) ; // read digital interface is assigned a value of 3 val
if (val == HIGH) // When the shock sensor detects a signal, LED flashes
{
digitalWrite (LedPin, LOW);
}
else
{
digitalWrite (LedPin, HIGH);
}
}
[/codesyntax]
Now simply move the module around and the LED on the Arduino board should light

