2015年4月18日 星期六

光度計之電路圖

圖一

圖二

作品名稱:光度計(FLUX METER)

材料:
光度sensor BH1750
紅綠藍 LED 若干個
74HC965 shift register

圖一顯示的是光度sensor的連接方法,通過sensor送出的類比訊號可以推知光強度
以下是code
[code]
// First define the library :
#include <BH1750FVI.h> // Sensor Library
#include <Wire.h> // I2C Library
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
uint16_t Light_Intensity=0;

// Call the function

BH1750FVI LightSensor;


void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  lcd.begin(16, 2);

//  call begin Function so turn the sensor On .
  LightSensor.begin();
  LightSensor.SetAddress(Device_Address_L); //Address 0x5C
  LightSensor.SetMode(Continuous_H_resolution_Mode);
  lcd.setCursor(0, 0);
  lcd.print("BH1750 Sensor");
  lcd.setCursor(1, 1);
  lcd.print("Please wait...");
  delay(3000);
  lcd.clear();

}

void loop() {
  // put your main code here, to run repeatedly:
   lcd.clear();
   lcd.setCursor(0, 0);
   lcd.print(" Intensity = ");
   lcd.setCursor(5, 1);
   Light_Intensity = LightSensor.GetLightIntensity();
   lcd.print(Light_Intensity);
   lcd.print(" Lux");
   delay(2000);
 
}


[/code]

圖二是光度計的另一個功能,我會通過分析光源的RGB值,分別用三排RGB LED來顯示個別單色光的強度。
通過 shift register, 我可以把LED燈位擴充到16位

再以其原理,通過arduino進行數位控制就可以達到我要的效果。

程式碼尚缺,遲些再補。

沒有留言:

張貼留言