diff --git a/PhotoReflectorIF/PhotoReflectorIF.ino b/PhotoReflectorIF/PhotoReflectorIF.ino index 5be4909..a3a9a78 100644 --- a/PhotoReflectorIF/PhotoReflectorIF.ino +++ b/PhotoReflectorIF/PhotoReflectorIF.ino @@ -14,6 +14,7 @@ #define CONTROL_2_LSB 0x09 // 固定時間モード,Highゲイン,Tint=01(1.4ms),積分時間1.4ms/ch #define SENSOR_REGISTER 0x03 #define SW_PIN 7 // スイッチ入力ピン +#define SYNC_OUT_PIN 8 // 同期出力ピン // 初期化 void setup() @@ -21,6 +22,7 @@ Serial.begin(115200);//シリアル通信を115200bpsで初期化 Wire.begin();//I2Cを初期化 pinMode(SW_PIN, INPUT_PULLUP); // デジタル入力初期化 + pinMode(SYNC_OUT_PIN, OUTPUT); // 同期出力初期化 Wire.beginTransmission(S11059_ADDR);//I2Cスレーブ データ送信開始 Wire.write(CONTROL_MSB);//コントロールバイトを指定 @@ -62,9 +64,10 @@ low_byte = Wire.read();//high_byteに「赤外(下位バイト)」のデータ読み込み IR = high_byte << 8|low_byte;//1Byte目のデータを8bit左にシフト、OR演算子で2Byte目のデータを結合して、IRに代入 } - Wire.endTransmission();//I2Cスレーブ「Arduino Uno」のデータ送信終了 + Wire.endTransmission();//I2Cスレーブ データ送信終了 sw = digitalRead(SW_PIN); + digitalWrite(SYNC_OUT_PIN, 1 - sw); Serial.print(blue);//「blue」をシリアルモニタに送信 Serial.print(",");//文字列「,」をシリアルモニタに送信