GR-COTTON LIGHT SENSOR

Pocket

前回GR-COTTONで人感センサで電灯のリモコンをON/OFFできるようになりました。昼間明るい時は、電灯をつける必要がありません。そこで照度センサを追加しました。照度センサは、GR-ADZUKIに搭載されているもセンサと同じセンサを使用しました。
照度センサ(フォトトランジスタ) NJL7502L (2個入)
http://akizukidenshi.com/catalog/g/gI-02325/
回路もGR-ADZUKIと同じ回路です。
http://gadget.renesas.com/ja/product/adzuki.html

プログラムの説明をします。
まず照度センサのアナログ入力ピンを宣言します。A5ピンを使用しました。
const int sensorPin = A5; // select the input pin for the light sensor
センサ入力値の変数を宣言します。
int sensorValue = 0; // variable to store the value coming from the sensor

loop()関数でアナログ入力値を読み込みます。
sensorValue = analogRead(sensorPin);

センサの値が10以下の暗い時だけONするようにしました。
if(sensorValue <= 10)
{
// ON
sendSignal(STATE_ON);
Serial.println(“ON “);
}

人が居なくなったら電灯がついているときだけ消灯します。
すでに消えているときは、消灯操作をしないようにしました。
if(sensorValue > 5)
{
// OFF
sendSignal(STATE_OFF);
Serial.println(“OFF1”);
}

昼間の非常に明るい時も消灯します。
if(sensorValue > 270)
{
// OFF
sendSignal(STATE_OFF);
Serial.println(“OFF2”);
}

100msec毎に繰り返します。
delay(100);

サンプルプログラムは以下にあります。
https://github.com/jendo1969/GR-COTTON/blob/master/Light_Sensor/Light_Sensor.ino

 

In the last time GR-COTTON it was possible to turn on / off the light remote control with the human sensor. When it is bright during the day, there is no need to turn on the light. I added an illumination sensor there. As for the illuminance sensor, the sensor same as the sensor which is installed in GR-ADZUKI was used.
Illuminance sensor (phototransistor) NJL 7502L (2 pieces)
http://akizukidenshi.com/catalog/g/gI-02325/
The circuit is also the same circuit as GR-ADZUKI.
http://gadget.renesas.com/ja/product/adzuki.html

I will explain the program.
First declare the analog input pin of the illuminance sensor. I used the A5 pin.

const int sensorPin = A5; // select the input pin for the light sensor
Declare variables for sensor input values.
int sensorValue = 0; // variable to store the value coming from the sensor

Read the analog input value with the loop() function.
sensorValue = analogRead(sensorPin);

We turned on only when the value of sensor is dark below 10.
if(sensorValue <= 10)
{
// ON
sendSignal(STATE_ON);
Serial.println(“ON “);
}

It turns off only when the light is on when people are gone.
When it has already disappeared, I turned off not to turn off.

if(sensorValue > 5)
{
// OFF
sendSignal(STATE_OFF);
Serial.println(“OFF1”);
}

It turns off even when it is very bright during the daytime.
if(sensorValue > 270)
{
// OFF
sendSignal(STATE_OFF);
Serial.println(“OFF2”);
}

Repeat every 100 msec.
delay(100);

The sample program is below.
https://github.com/jendo1969/GR-COTTON/blob/master/Light_Sensor/Light_Sensor.ino

 

 

在最後一次使用GR-COTTON時,可以用人體感應器打開/關閉遙控器。 當白天很亮時,不需要打開燈。 我在那裡加了一個照明傳感器。 對於照度傳感器,使用與安裝在GR-ADZUKI中的傳感器相同的傳感器。
照度傳感器(光電晶體管)NJL 7502L(2個)
http://akizukidenshi.com/catalog/g/gI-02325/
該電路也是GR-ADZUKI的電路。
http://gadget.renesas.com/ja/product/adzuki.html

我會解釋這個程序。
首先聲明照度傳感器的模擬輸入引腳。 我使用了A5引腳。

const int sensorPin = A5; // select the input pin for the light sensor
聲明傳感器輸入值的變量。
int sensorValue = 0; // variable to store the value coming from the sensor

l使用loop)函數讀取模擬量輸入值。
sensorValue = analogRead(sensorPin);

只有當傳感器的值低於10時我們才開啟。
if(sensorValue <= 10)
{
// ON
sendSignal(STATE_ON);
Serial.println(“ON “);
}

只有當人們走後燈亮時才會關閉。
當它已經消失時,我關掉了不關閉。

if(sensorValue > 5)
{
// OFF
sendSignal(STATE_OFF);
Serial.println(“OFF1”);
}

即使在白天非常亮的時候也會關閉。
if(sensorValue > 270)
{
// OFF
sendSignal(STATE_OFF);
Serial.println(“OFF2”);
}

每100毫秒重複一次。
delay(100);

示例程序如下。
https://github.com/jendo1969/GR-COTTON/blob/master/Light_Sensor/Light_Sensor.ino

 

 

 

Post Tagged with ,

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください