Friday, July 11, 2014

How to Work With HDX2 Vibration Switch Sensor using Arduino UNO.

Hi, This is my Very First Tutorial about How to work with HDX2 Vibration Switch Sensor using Arduino UNO.
  • No Libraries needed.
  • No Advance knowledge needed. 
 All you need are,

  • 1 x HDX2 Vibration Switch Sensor.
  • 1 x Arduino UNO board with USB cable ( or Lakduino ).
  • 2 x Male to Female Jumper Cables.
  • ( 1 x LED bulb if you need. )
OK.. Lets see How to do it..

  1. Connect the jumper wire's female end to HDX2 Vibration Switch Sensor.

  1. Connect Male ends to Arduino's 3 (digital) and GND (ground) ends.





If You have a LED connect it's (+) to Arduino's 13th female end And (-) to Arduino's GND

OK.. you Done..

     3.  Copy This Code to Your Arduino IDE.

-----------------------------------------------------

int ledPin = 13;
int sensor = 3;


void setup() {
  pinMode(ledPin, OUTPUT);
  pinMode(sensor, INPUT);

}

void loop() {
  if(digitalRead(sensor)==HIGH){
    digitalWrite(ledPin, HIGH);
    delay(1000);
  }else{
    digitalWrite(ledPin, LOW);
  }
}


-----------------------------------------------------

     4.  Compile and Upload to Arduino. 

You've Done !!  ;)

The LED or (and) Arduino's 13th pin's LED will blink when HDX2 Vibration Switch Sensor can sens a Vibrate !
Good Luck..



Any Questions ?? Comment Below.. :)