GR-COTTON PYROELECTRIC SENSOR
前回GR-COTTONで電灯のリモコンをON/OFFできるようになりました。人が居るときに自動的に点灯できるように焦電センサを追加しました。
焦電型赤外線センサーモジュール(焦電人感センサ) SB612A
http://akizukidenshi.com/catalog/g/gM-08767/
プログラムの説明します。
焦電センサとの接続を5ピンとします。
const int PIR = 5;
焦電センサの入力状態を保存する変数を宣言します。
int PIR_STATE;
setup()関数で焦電センサとの接続ピンを入力に設定します。
pinMode(PIR, INPUT);
loop()関数で焦電センサの状態を読み取ります。
PIR_STATE = digitalRead(PIR);
焦電センサは、人を検知したときLOWになります。
よってLOWの時、電灯を点け、HIGHで電灯を消します。
if(PIR_STATE == LOW)
{
// ON
sendSignal(STATE_ON);
}
else
{
// OFF
sendSignal(STATE_OFF);
}
3秒ごとに処理を繰り返します。
delay(3000);
サンプルプログラムは以下にあります。
https://github.com/jendo1969/GR-COTTON/blob/master/PIR_Sensor/PIR_Sensor.ino
You can now turn on / off the light remote control with GR – COTTON last time. A pyroelectric sensor was added so that it can be turned on automatically when a person is present.
Pyroelectric infrared sensor module (pyroelectric human sensor) SB 612 A
http://akizukidenshi.com/catalog/g/gM-08767/
Explanation of the program.
Connect to the pyroelectric sensor as 5 pins.
const int PIR = 5;
Declare a variable to save the input state of the pyroelectric sensor.
int PIR_STATE;
Use the setup() function to set the connection pin to the pyroelectric sensor to input.
pinMode(PIR, INPUT);
Read the state of the pyroelectric sensor with the loop() function.
PIR_STATE = digitalRead(PIR);
The pyroelectric sensor becomes LOW when a person is detected.
Therefore, turn on the light when LOW, turn off the light by HIGH.
if(PIR_STATE == LOW)
{
// ON
sendSignal(STATE_ON);
}
else
{
// OFF
sendSignal(STATE_OFF);
}
Repeat processing every 3 seconds.
delay(3000);
The sample program is below.
https://github.com/jendo1969/GR-COTTON/blob/master/PIR_Sensor/PIR_Sensor.ino
您現在可以上次使用GR-COTTON打開/關閉遙控器。 增加了熱釋電傳感器,以便在有人存在時自動啟動。
熱釋電紅外傳感器模塊(熱釋電人體傳感器)SB 612 A
http://akizukidenshi.com/catalog/g/gM-08767/
該方案的解釋。
以5個引腳連接到熱釋電傳感器。
const int PIR = 5;
聲明一個變量來保存熱釋電傳感器的輸入狀態。
int PIR_STATE;
使用setup()函數將熱電傳感器的連接引腳設置為輸入。
pinMode(PIR, INPUT);
用loop()函數讀取熱電傳感器的狀態。
PIR_STATE = digitalRead(PIR);
當檢測到人時,熱電傳感器變為低電平。
因此,在低電平時打開燈,用HIGH關閉燈。
if(PIR_STATE == LOW)
{
// ON
sendSignal(STATE_ON);
}
else
{
// OFF
sendSignal(STATE_OFF);
}
每3秒重複處理一次。
delay(3000);
示例程序如下。
https://github.com/jendo1969/GR-COTTON/blob/master/PIR_Sensor/PIR_Sensor.ino