Home Arduino KY-002 Vibration Shock Sensor

KY-002 Vibration Shock Sensor

by iainhendry

The KY-002 Vibration Shock Sensor

This vibration detector switch is OFF in the normal state, when there is enough force then the switch is in an ON state

Connection

Connect the Power line (middle) and ground (-) to +5 and GND. Connect signal (S) to pin 3 on the Arduino.

KY-002 Arduino
S Pin 3
middle +5V
GND

Code

[codesyntax lang=”cpp”]

int Led=13;
int Shock=3;
int val;

void setup()
{
pinMode(Led,OUTPUT);
pinMode(Shock,INPUT);
}

void loop()
{
val=digitalRead(Shock);
if(val==HIGH)
{
digitalWrite(Led,LOW);
}
else
{
digitalWrite(Led,HIGH);
}
}

[/codesyntax]

Links

37 in 1 box Sensor Kit For Arduino Starters brand in stock

You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More