Wednesday 28 January 2015

10 . Using vibration sensor in Ardunio


How much ever secure we keep our house there always exist some vulnerability to break into.This post explains how to use a vibration sensor with use of Arduino.
The Sensor detects any type of vibrations and returns Vcc as output. Its interface to Arduino is very simple in a way that the output of the sensor is fed to any of the I/O pins of the Arduino and is stored in some variable. If the IO pin of the Arduino returns a HIGH then there is a vibration on the sensor else the state of arduino will be in monitoring mode.

Calibration

There is a small potentiometer on the sensor which measures the depth of vibration to detect and act accordingly.Based on the value of the potentiometer the sensitivity of the sensor decreases or increases.


Diagram:


Program

// The following program blinks an LED when the sensor detects vibration
void setup()
{
   pinMode(3,INPUT);
   pinMode(13,OUTPUT);
}
void loop()
{
  int sensorinput=digitalRead(3);
  if (sensorinput==HIGH)
  {
            digialWrite(13,HIGH);
  }
  else
  {
           digitalWrite(13,LOW);
 }
}