DFRobot Digital Vibration Sensor V2 SKU:DFR0027
Contents
1 Introduction
2 Specification
3 Tutorial
3.1 Connection Diagram
3.2 Sample Code
3.3 Result
4 Trouble shooting
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
Wide voltage range from 3.3V to 5V
Standard assembling structure (two 3mm diameter holes with multiple of 5mm as distance from
center)
Easily recognitive interfaces of sensors ("A" for analog and "D" for digital)
Icons to simplely illustrate sensor function
High quality connector
Immersion gold surface
IO Type: Digital
Switch life: up to 10 million seconds
Open circuit resistance: 10Mohm
Supply Voltage: 3.3V to 5V
Interface: Digital
Size:22x30mm
Tutorial
Connection Diagram
Sample Code
#define SensorLED
13
//Connect the sensor to digital Pin 3 which is Interrupt
s 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++;
}
{|
1 #define SensorLED
13
2 //Connect the sensor to digital Pin 3 which is Interr
upts 1.
3 #define SensorINPUT
3
4
5 unsigned char state = 0;
6
7 void setup() {
8
pinMode(SensorLED, OUTPUT);
9
pinMode(SensorINPUT, INPUT);
10
//Trigger the blink function when the falling edge
is detected
11
attachInterrupt(1, blink, FALLING);
12 }
13
14 void loop() {
15
if (state != 0) {
16
state = 0;
17
digitalWrite(SensorLED, HIGH);
18
delay(500);
19
}
20
else
21
digitalWrite(SensorLED, LOW);
22 }
23
24 //Interrupts function
25 void blink() {
26
state++;
27 }
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
Powered By DFRobot © 2008-2017
很抱歉,暂时无法提供与“DFR0027”相匹配的价格&库存,您可以联系我们找货
免费人工找货- 国内价格
- 1+37.52707
- 3+33.13115
- 9+32.64005