By using this website, you agree to the use of cookies as described in our Privacy Policy.

KY-002 - Vibrationsensor Modul

KY-002 - Vibrationsensor Modul

KY 002Einführung

Bei dem Modul handelt es sich um einen Vibrationsschalter. Im Beispiel blinkt die LED 13 des Arduino, wenn eine Vibration gemessen wird

Anschluss

ArduinoModul
GND Pin -
+5V Pin (middel pin) +5 v
Pin 10 Pin S signal
 

Beispielcode

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);
  }
}
  • Zugriffe: 315

Related Articles