I have bought this vibration sensor: http://i40.tinypic.com/vpksxh.jpg
At first I thought that it will work like a button(if vibrates it give digital HIGH, else LOW).
But in reality it works only with this code:
#define SensorLED 13
#define SensorINPUT 2
unsigned char state = 0;
attachInterrupt(0, blink, FALLING);//D2 interface: interrupt 0. call blink()
state = 0;
void blink()//when input falling edge, this interrupt function works.
//the result is the LED( PIN 13 ) will light 500ms after the Shock.
Can somebody explain me how this code works? Is it possible to change sensors sensitivity with the code?
Thank you very much!