Skip to main content

How to use a Flat Vibration Switch

What is a Flat Vibration Switch?

This is a low-sensitivity, directional vibration-induced trigger switch. Inside is a very soft spring coiled around a long metal pin. When the switch is bumped from the side only, the spring attached to the first pin touches the center pole to make contact with the second pin. So when there's a bump, the two pins will act like a closed switch. When everything is still, the switch is open.

Wiring

  • one pin to GND & D2 via 10k resistor
  • one pin to 5V flatVibrationSwitch.png

Getting started

const int vibrationPin = 2;  // Pin connected to vibration switch
const int ledPin = 13;       // Built-in LED on most Arduino boards

void setup() {
 
  Serial.begin(9600);
}

void loop() {
  int state = digitalRead(vibrationPin);
  if (state == HIGH) {
    digitalWrite(ledPin, HIGH);
    Serial.println("Vibration detected!");
  } else {
    digitalWrite(ledPin, LOW);
  }
  delay(100);
}