Puzzle - Collision Sensor 碰撞传感器

来自Duinopeak_COM
跳转至: 导航搜索

产品简介

puzzle - Collision Sensor可以检测碰撞和振动,当检测到时会输出一个脉冲信号。为了使输出信号更稳定准确,我们增加了电路去过滤噪音,因此正常的振动不会促发信号输出。

Puzzle Collision sensor top.jpgPuzzle Collision sensor back.jpg



参数规格

  • Voltage: 5V



应用示例

这个示例我们用碰撞传感器来检测振动,进而点亮LED,即当振动时LED点亮。将碰撞传感器连接至数字口D2,将LED连接至数字口D13;

Puzzle Collision sensor connection.jpg


/****************************************************************************/	
//	Function: Monitor if there is any collision
//	Hardware: puzzle - Collision Sensor
//	Arduino IDE: Arduino-1.0
//	by www.duinofunstudio.com
//
//  This library is free software; you can redistribute it and/or
//  modify it under the terms of the GNU Lesser General Public
//  License as published by the Free Software Foundation; either
//  version 2.1 of the License, or (at your option) any later version.
//
//  This library is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//  Lesser General Public License for more details.
//
//  You should have received a copy of the GNU Lesser General Public
//  License along with this library; if not, write to the Free Software
//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
/*******************************************************************************/ 

#define LED 13 //the onboard LED of Arduino or duinofunuino
#define COLLISION_SENSOR 2//collision sensor is connected with D2 of Arduino
void setup()
{
	pins_init();
}

void loop()
{
    if(isTriggered())
    {
       turnOnLED();
	   delay(2000);
 	}
	else turnOffLED();
 }
void pins_init()
{
    pinMode(LED,OUTPUT);
    turnOffLED();
    pinMode(COLLISION_SENSOR,INPUT);
}
boolean isTriggered()
{
    if(digitalRead(COLLISION_SENSOR))
    {
         delay(50);  
        if(digitalRead(COLLISION_SENSOR))
  	return true;//the collision sensor triggers
     }
    return false;
}
void turnOnLED()
{
	digitalWrite(LED,HIGH);//the LED is on
}
void turnOffLED()
{
	digitalWrite(LED,LOW);//the LED is off
}


  • 我们可以通过代码中的delay(50)来调整传感器灵敏度。
    if(digitalRead(COLLISION_SENSOR))
    {
         delay(50);  //change the delay time to adjust sensitiity. The smaller the value,the higher the sensitivity.
        if(digitalRead(COLLISION_SENSOR))
  	return true;//the collision sensor triggers
     }
    return false;



资源


Puzzle - Collision Sensor 碰撞传感器原理图PDF: 文件:Puzzle Collision sensor schematic.pdf


如何购买

Duinopeak 官方淘宝商城
Collision Sensor 碰撞传感器购买链接

支持

如果你有什么建议或者好的点子, 你可以来我们的DuinoPeak论坛参与讨论.

外部链接

链接到外部网页将会给你提供更多应用创意,文档/数据表或软件库

视频