GR-ADZUKI ANALOG INPUT SAMPLE

Pocket

アナログ入力の使用方法を説明します。
GR-ADZUKIには、8個のアナログ入力があります。
A0、A1は、SENSOR0、1として出ています。
A2は、ライトセンサーにつながっています。
A3、A4、A5は、加速度センサにつながっています。
A6、A7は、ピンソケットにつながっています。
ここでは、ライトセンサーの値をA2から読み込む方法を説明します。
ライトセンサは、以下の物がついています。
照度センサ(フォトトランジスタ) NJL7502L
http://akizukidenshi.com/catalog/g/gI-02325/
ライトセンサのアナログ入力A2を定義します。
LED6を指標に使うので定義します。
センサーの入力値を保持する変数を宣言します。
int sensorPin = A2; // select the input pin for the light sensor
int LED6 = 13; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor

setup()関数でLED6を出力ピンに設定します。
pinMode(LED6, OUTPUT);

loop()関数を見ていきます。
まず、analogRead()関数でアナログ入力A2の値を読み出します。
// read the value from the sensor:
sensorValue = analogRead(sensorPin);

次にLEDを点灯します。
// turn the ledPin on
digitalWrite(LED6, HIGH);

センサーの値だけセンサー値を待機します。
// stop the program for <sensorValue> milliseconds:
delay(sensorValue);

次にLEDを消灯します。
// turn the ledPin off:
digitalWrite(LED6, LOW);

最後にセンサーの値だけセンサー値を待機します。
// stop the program for for <sensorValue> milliseconds:
delay(sensorValue);

センサーの値が大きいほどゆっくり点滅します。ライトセンサなので光に反応します。GR-ADZUKIを照明にかざすとゆっくり点滅します。GR-ADZUKIを暗いところに置くと早く点滅します。センサの入力値による変化が確認できると思います。

サンプルは以下にあります。
https://github.com/jendo1969/GR-ADZUKI/blob/master/AnalogInput.ino


I will explain how to use the analog input.

GR-ADZUKI has 8 analog inputs.
A0, A1 are output as SENSOR 0, 1.
A2 is connected to the light sensor.
A3, A4, A5 are connected to the acceleration sensor.
A6, A7 are connected to the pin socket.
Here, we explain how to read the value of the light sensor from A2.
The following items are attached to the light sensor.
Illuminance sensor (phototransistor) NJL 7502L
http://akizukidenshi.com/catalog/g/gI-02325/

Set the LED 6 to the output pin with the setup () function.
pinMode(LED6, OUTPUT);

Define the analog input A2 of the light sensor.
Define as using LED 6 as an indicator.
Declare a variable to hold the input value of the sensor.

int sensorPin = A2; // select the input pin for the light sensor
int LED6 = 13; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor

Let’s look at the loop () function.
First, read the value of analog input A2 with the analogRead () function.

// read the value from the sensor:
sensorValue = analogRead(sensorPin);

Then turn on the LED.
// turn the ledPin on
digitalWrite(LED6, HIGH);

Wait for sensor value for sensor value.
// stop the program for <sensorValue> milliseconds:
delay(sensorValue);

Then turn off the LED.
// turn the ledPin off:
digitalWrite(LED6, LOW);

Finally wait for the sensor value by the value of the sensor.
// stop the program for for <sensorValue> milliseconds:
delay(sensorValue);

The larger the value of the sensor, the slower it flashes. Because it is a light sensor, it responds to light. When GR-ADZUKI is held over the lighting, it flashes slowly. When GR – ADZUKI is placed in a dark place it flashes quickly. I think that change due to sensor input value can be confirmed.

Samples are below.

https://github.com/jendo1969/GR-ADZUKI/blob/master/AnalogInput.ino

 

我將解釋如何使用模擬輸入。
GR-ADZUKI有8個模擬輸入。
A0,A1輸出為SENSOR 0,1。
A2連接到光線傳感器。
A3,A4,A5連接到加速度傳感器。
A6,A7連接到插座。
在這裡,我們解釋如何從A2讀取光線傳感器的值。
以下項目附在光線傳感器上。
照度傳感器(光電晶體管)NJL7502L

http://akizukidenshi.com/catalog/g/gI-02325/

定義光傳感器的模擬輸入A2。
定義為使用LED 6作為指示器。
聲明一個變量來保存傳感器的輸入值。

int sensorPin = A2; // select the input pin for the light sensor
int LED6 = 13; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor

使用setup()函數將LED 6設置到輸出引腳。
pinMode(LED6, OUTPUT);

我們來看看loop()函數。
首先,用analogRead()函數讀取模擬輸入A2的值。

// read the value from the sensor:
sensorValue = analogRead(sensorPin);

然後打開LED。

// turn the ledPin on
digitalWrite(LED6, HIGH);

等待傳感器值的傳感器值。
// stop the program for <sensorValue> milliseconds:
delay(sensorValue);

然後關掉LED。
// turn the ledPin off:
digitalWrite(LED6, LOW);

最後等待傳感器的值由傳感器的值。
// stop the program for for <sensorValue> milliseconds:
delay(sensorValue);

傳感器的值越大,閃爍越慢。 因為它是一個光傳感器,它對光線有反應。 當GR-ADZUKI被擱置在照明上時,它緩慢地閃爍。 當GR – ADZUKI被放置在黑暗的地方時,它會很快閃爍。 我認為可以確認由於傳感器輸入值的變化。

樣本如下。
https://github.com/jendo1969/GR-ADZUKI/blob/master/AnalogInput.ino

Post Tagged with , ,

コメントを残す

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

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