906
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