Introduction

What's the simplest way to check vibration with Arduino? Use a vibration sensor from DFRobot. You can directly plug it on our IO Expesion Shield V7. Just vibrate this sensor, Arduino can receive a digital signal. It's easy to acount and program in Arduino.

Despite it's simple, you can make full use of it with creative thinking, like step counting, Crash warning light and so on.

Specification

Tutorial

Connection Diagram

connection diagram

Sample Code

#define SensorLED   13
//Connect the sensor to digital Pin 3 which is Interrupts 1.
#define SensorINPUT  3
unsigned char state = 0;

void setup() {
  pinMode(SensorLED, OUTPUT);
  pinMode(SensorINPUT, INPUT);
  //Trigger the blink function when the falling edge is detected
  attachInterrupt(1, blink, FALLING);
}

void loop() {
  if (state != 0) {
    state = 0;
    digitalWrite(SensorLED, HIGH);
    delay(500);
  }
  else
    digitalWrite(SensorLED, LOW);
}
 
//Interrupts function 
void blink() {
    state++;
}
#define SensorLED   13
//Connect the sensor to digital Pin 3 which is Interrupts 1.
#define SensorINPUT  3
 
unsigned char state = 0;
 
void setup() {
  pinMode(SensorLED, OUTPUT);
  pinMode(SensorINPUT, INPUT);
  //Trigger the blink function when the falling edge is detected
  attachInterrupt(1, blink, FALLING);
}

void loop() {
  if (state != 0) {
    state = 0;
    digitalWrite(SensorLED, HIGH);
    delay(500);
  }
  else
    digitalWrite(SensorLED, LOW);
}
 
//Interrupts function 
void blink() {
    state++;
}

Result

As shown in figure connection , plug LED and lay a finger on Digital Vibration Sensor , LED will be lightened

Trouble shooting

More question and cool idea, visit DFRobot Forum

More Documents

DFshopping_car1.png Get DFRobot DFRobot Digital Vibration Sensor V2_SKU:DFR0027 from DFRobot Store or DFRobot Distributor.

Turn to the Top