Vibration sensor with switch and sensitivity adjustment (model SW-420).
Approximate size: 33 x 14 x 8 mm.
The breakout board contains an LM393 op-amp IC but it is used as a comparator and not an amplifier. Basically, the D0 pin goes high when there is vibration and goes low when there isn’t. You can adjust the sensitivity of the sensor by turning the trimmer on the board.
The board comes with two LEDs: one for power indication and one tied directly to D0. When the D0 pin is high, the D0 LED turns off and vice versa. Yeah, it’s the opposite of what we would like the LED to do.
int SW420 = 3;
void setup(){
pinMode(SW420, INPUT);
Serial.begin(9600);
}
void loop(){
delay(10);
long pulseWidth = pulseIn (SW420, HIGH);;
delay(50);
Serial.println(measurement);
if (pulseWidth > 1000){
Serial.println(“The Titans are coming!”);
}
else{
digitalWrite(“Tranquility is here”);
}
}