KY-002 Vibration-switch module
KY-002 Vibration-switch module
Contents 1 Picture . 1 2 Technical Data / Short discription 1 3 Pinout . . . 2 4 Code example Arduino . . 2 5 Code example for Raspberry Pi . . . 3
Picture
Technical Data / Short discription
On vibration, the contact of the two input pins will be connected.
Export: 16. 06. 2017
Copyright by Joy-IT - Published under CC BY-NC-SA 3. 0
Page 16 of 214
KY-002 Vibration-switch module
Pinout
Code example Arduino
This example will activate a LED as soon as the sensor detects a signal. The modules KY-011, KY-016 or KY-029 can be used as a LED.
int Led = 13 ;// Declaration of the LED output pin int Sensor = 10; // Declaration of the Sensor input pin int val; // Temporary variable void setup () {
pinMode (Led, OUTPUT) ; // Initialisation output pin pinMode (Sensor, INPUT) ; // Initializstion sensor pin digitalWrite(Sensor, HIGH); // Activating of the internal pull-up resistors } void loop () { val = digitalRead (Sensor) ; // The active signal at the sensor will be read if (val == HIGH) // If a signal was noticed, the LED will be on {
digitalWrite (Led, LOW); } else {
digitalWrite (Led, HIGH); } }
Connections Arduino:
LED + LED Sensor Signal
= [Pin 13] = [Pin GND] = [Pin 10]
Export: 16. 06. 2017
Copyright by Joy-IT - Published under ...