johnpaulada
2/16/2017 - 12:28 AM

Arduino code for the vibration sensor.

Arduino code for the vibration sensor.

const int LED_OUT = 13;
const int TILT_IN = 3;
unsigned int state = 0;

void setup() {
  pinMode(LED_OUT, OUTPUT);
  pinMode(TILT_IN, INPUT);
  attachInterrupt(1, blink, RISING);
}

void loop() {
  if (state!=0) {
    state = 0;
    digitalWrite(LED_OUT, HIGH);
    delay(1000);
  } else {
    digitalWrite(LED_OUT, LOW);
  }
}

void blink() {
  state++;
}