- No Libraries needed.
- No Advance knowledge needed.
- 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. )
- Connect the jumper wire's female end to HDX2 Vibration Switch Sensor.
- 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.. :)
can we use this sensor as an analog input using threshold level.
ReplyDeleteYes.. You can do it.. preview your sensor's incoming data with simple code given below. if you want some sample code let me know. thanks
DeleteSerial.print(analogRead(sensor));
Hi, Can the code be amended so that it can have 6 vibration sensors and 6 LED's so that each vibration sensor lights a different LED?
ReplyDeleteHi, Please declare 6 variables for each LEDs and 6 Variables for each sensors.
Deletethen filter results with if-else ladder.
Thanks.
I have tried this code and cannot get it to work. not sure what I am doing wrong.
ReplyDeleteYou don't get any results ? even an error ?
DeleteI finally got it working but had to go through a pull-up resistor.
ReplyDeleteCan we use this sensor as earthquake detector? Is this sensor same with SW420? Which have better sensitivity? Thanks
ReplyDeleteBlackjack from The Grand Victoria Casino - Mapyro
ReplyDeleteBlackjack 문경 출장샵 From The 남양주 출장마사지 Grand Victoria Casino is a fun, 거제 출장마사지 exciting, and 목포 출장안마 fun casino table game featuring the same 군포 출장마사지 rules as standard blackjack.