1 簡介
Me PIR Motion Sensor 是用來檢測人或動物身體上發出的紅外輻射的模塊,最大測量範圍為6m。如果有人靠近到量程內,DOPin將會輸出有效信號。本模塊需要連接到主板上帶有藍色標識接口。
2 特性
- l 支持Arduino IDE, 並且我們提供了運行庫來簡化編程;
- l 支持MBlock,適合全年齡用戶;
- l 使用RJ25接口連線十分容易;
- l 模塊化安裝,兼容樂高系列;
- l 配有接頭支持絕大多數Arduino系列主控板。
3 參數
- l 運行電壓: 5V 直流;
- l 保持時間: 2s;
- l 探測角度:120 °範圍內;
- l 尺寸: 52 x 24 x 16 mm (長x寬x高);
4 接口介紹
4.1 RJ25 接口
當使用RJ25接口時,請鏈接到有藍色標識的Makeblock主控板(Meduino+ Base Shield, Me Baseboard, Makeblock Orion, etc )的接口上。以Me baseboard1.1版的主板為例,可以鏈接到3,4,5,6,7,8 號接口,如圖:
圖1 Me PIR Motion Sensor 與Me Baseboard V1.1鏈接圖
4.2 Pin 接 口
Me PIR Motion Sensor 模塊有四個針腳的接頭,每個針腳的功能如下表:
表1 4-Pin 接頭功能表
可以通過4pin接頭用其他的控制板來控製本模塊。Mode-pin 和Do-pin 需要鏈接到DIGITAL(數字) pin。如下圖所示,鏈接到Arduino Uno的方法:
圖2 Me PIR Motion Sensor module 與Arduino UNO連接圖
5 編程指南
5.1 ArduinoIDE
在Arduino IDE界面下,您可以使用此運行庫Makeblock-Library-master來控制Me PIR Motion Sensor如下是控制方程列表:
表2 Me PIR Motion Sensor 方程功能列表
以下是如何通過Arduino IDE控制Me PIR MotionSensor的例子:
*********************************代碼**************** *******************
- #include<Makeblock.h>
- #include<SoftwareSerial.h>
- #include<Wire.h>
- MePIRMotionSensor PIRmotion_val(PORT_3);
- bool value = 0; // a variable for the PIRMotion Sensor
- void setup()
- {
- // initialize serial communications at 9600bps
- Serial.begin(9600);
- }
- void loop()
- {
- // read the PIR Motion Sensor values:
- value = PIRmotion_val.isPeopleDetected();
- // print the results to the serial monitor:
- Serial.print("PIR Motion Values = ");
- Serial.println(value);
- // wait 100 milliseconds before the next loop
- delay(100);
- }
[color=rgb(2, 104, 144) !important]複製代碼
************************************************** ********************
代碼功能介紹: 讀取Do-pin的檢測結果,將結果輸出到Arduino IDE Serial Monitor, 週期為100ms。上傳代碼到Makeblock主板點擊Arduino Serial Monitor 您將看到運行結果如下:
如果檢測到運動, 返回數值將會是“1”,否則是“0”。您還可以通過電位計來改變監測範圍,最大範圍為6 m。
5.2 Mblock
Me PIR Motion Sensor模塊支持MBlock編程環境.如下是Me PIR Motion Sensor控制模塊簡介:
以下是如何使用MBlock控制Me PIR Motion Sensor 模塊的例子:
當模塊沒有檢測到有人移動時, 小貓會說“Nobody here!”. 反之,小貓會說“Somebody here!”. 運行結果如下: