Monday, June 13, 2016

SW-18010P Vibration Sensor Module


This module uses SW-18010P spring type vibration switch to detect vibration of the surrounding environment. It does not require a large amount of vibration to generate triggering effect. A green LED light on the module will turn on when the module is shaken or external force is applied to the sensor. Sensitivity is adjustable via the blue digital potentiometer.

In the circuit below, the module's digital pin D0 connects to the the Arduino's digital pin 12. Put it simply, pin 12 is used to detect the high and low level. The Arduino's built-in LED light will be activated when vibration is detected. Keep in mind that when there is no vibration, the output from the sensor is HIGH. The opposite applies when the sensor detects vibration.


int ledPin=13;
int sensorPin=12;
int sensorValue=0;
 
void setup ()
{
  pinMode(ledPin,OUTPUT) ;
  digitalWrite(ledPin,LOW);
  pinMode(sensorPin,INPUT) ;
}
 
void loop ()
{
  sensorValue=digitalRead(sensorPin);
  if(sensorValue==HIGH)
  {
    digitalWrite(ledPin,LOW);
  }
  else
  {
    digitalWrite(ledPin,HIGH);
  }  
}

No comments:

Post a Comment