数字震动传感器

简介

DFRobot数字震动传感器是一个数字的即插即用传感器模块。它可以检测到震动信号,然后输出开关信号到Arduino,

模块使用PH2.0接口,使用数字连接线可以很方便的连接到传感器扩展板上。

它能够感知微弱震动信号,可实现与震动有关的互动作品。

产品参数

使用教程

连线图

数字模块链接示意图

示例代码

#define SensorLED     13
#define SensorINPUT   3  //Connect the sensor to digital Pin 3 which is Interrupts 1.

unsigned char state = 0;

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

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


void blink()//Interrupts function
{
  state++;
}

Mind+(基于Scratch3.0)图形化编程

1、下载及安装软件。下载地址:http://www.mindplus.cc 详细教程:Mind+基础wiki教程-软件下载安装 2、切换到“上传模式”。 详细教程:Mind+基础wiki教程-上传模式编程流程 3、“扩展”中选择“主控板”中的“Arduino Uno”,“传感器”中加载“数字震动传感器”。 详细教程:Mind+基础wiki教程-加载扩展库流程 4、进行编程,程序如下图: 5、菜单“连接设备”,“上传到设备”

结果

如图连线,引脚13插上LED小灯后,每次振动数字震动传感器,小灯都会短暂点亮,具体点亮时间可在代码中设置

疑难解答

更多问题及有趣的应用,请访问论坛

更多

<File:nextredirectltr.png>购买 DFRobot商城购买链接

category: Product Manual category: DFR Series category: Sensors category:source category:Diagram