常用传感器讲解七--红外警报传感器(KY-008)

简介: 常用传感器讲解七

具体讲解截屏2023-12-27 下午7.30.18.png

这个是一种由身体运动触发的设备,可以使用它来检测人,动物,汽车……经过某个区域时的情况。这是一个基于LASER发射器的设备,该发射器不断向光学传感器发送光束,当有人/某物通过时,传感器将不会接收到光束,并且会触发警报。
该项目基于模块,LASER模块,蜂鸣器和按钮,其概念非常简单,LASER不断向模块传感器投射光线,当有人或其他物体通过光束时,传感器会不再检测到光(当光停止时,LDR将增加电阻,这意味着将流过的电流减少,并且我们将得到一个电压降)。

例子项目:在室内光线下,使用Arduino时使用“ analogRead”功能时,传感器将给出“ 750”左右的值,而使用Arduino时传感器将给出“ 3.66V”(5V的值为1023)左右,但是当遮盖传感器时,传感器将给出大约“ 750”左右的值。 “ 10-15”代表“ 40mV”。因此,最好将传感器盖住或放置在只有激光束可以到达的情况下。

一旦激光光束被切割,即使模块再次检测到激光,警报也会响起并且直到按下按钮时才会停止。

电路连接

截屏2023-12-27 下午7.30.37.png

代码部分

#define Rec 0      //Light sensor output
#define Laser 2    //Laser module 
#define Button 3   //Push button input

bool detection;

void setup() {
   
   
  pinMode(Laser, OUTPUT);
  digitalWrite(Laser, HIGH); //Turning on the laser
  delay(2000);
}

void loop() {
   
   

 short Detect = analogRead(Rec);            //Constanly reading the module value
 bool  Button_state = digitalRead(Button);  //And the button value (1-0)

 if(Detect < 500)              //The Max value is 760, if someone passes it goes below that (every value lower than 700 can do the work)
    detection = true;          //The detection is triggered

 if(detection==true)
    {
   
   
       tone(13,2000);        //Alarm sequence will go on as long as the detection is true
       delay(50);            //This alarm has two sounds 2kHz nd 1Khz delayed by 50ms
       tone(13,1000);
       delay(50);
    }

 if(Button_state == HIGH)  //If the button is pressed the buzzer is turned off and the detection too
    {
   
   
      detection = false;
      noTone(13);
    }


}
相关文章
|
SQL 存储 大数据
大数据Hive DDL其他语法
大数据Hive DDL其他语法
384 1
|
12月前
|
数据可视化 数据挖掘 数据建模
数据可视化工具大比拼:从Tableau到Power BI,谁才是你的最佳拍档?
数据可视化工具大比拼:从Tableau到Power BI,谁才是你的最佳拍档?
1430 12
|
Dubbo 应用服务中间件 Apache
Star 4w+,Apache Dubbo 3.3 全新发布,Triple X 领衔,开启微服务通信新时代
在 Apache Dubbo 突破 4w Star 之际,Apache Dubbo 团队正式宣布,Dubbo 3.3 正式发布!作为全球领先的开源微服务框架,Dubbo 一直致力于为开发者提供高性能、可扩展且灵活的分布式服务解决方案。此次发布的 Dubbo 3.3,通过 Triple X 的全新升级,突破了以往局限,实现了对南北向与东西向流量的全面支持,并提升了对云原生架构的友好性。
480 103
|
Python
在python中使用SimpleImputer类(来自scikit-learn库)
在python中使用SimpleImputer类(来自scikit-learn库)
980 46
|
监控
LabVIEW通过OPC与PLC通讯
LabVIEW通过OPC与PLC通讯
579 0
|
小程序 JavaScript 前端开发
微信小程序控制元素显示隐藏
微信小程序控制元素显示隐藏
682 0
|
计算机视觉 机器学习/深度学习 Python
YOLOv5改进系列(3)——添加CA注意力机制
YOLOv5改进系列(3)——添加CA注意力机制
6048 0
YOLOv5改进系列(3)——添加CA注意力机制