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

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);
}

Revision #2
Created 26 June 2025 14:39:22 by Joanne Leung
Updated 26 June 2025 14:56:39 by Joanne Leung