# 數位式光強度感測器模組

## 數位式光強度感測器模組 <a href="#toc124882502" id="toc124882502"></a>

**專案說明**

使用「Raspberry Pi Pico W」連接「數位式光強度感測器模組」, 讀取數位式光強度感測器模組的數值變化。此 **數位式光強度感測器模組**包含於「洞洞五教學材料包」內。

### **數位式光強度感測器模組電路圖**

* Raspberry Pi Pico W
* Raspberry Pi Pico W 擴充板
* 數位式光強度感測器模組

**數位式光強度感測器模組**是**I2C訊號**輸入。本範例連接到模組SDA腳位需接至Raspberry Pi Pico W擴充板D4腳位，模組SCL腳位需接至Raspberry Pi Pico W擴充板D5腳位。

![](https://1275793585-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LaZQFBYOS3O0ksiEmR1%2Fuploads%2F8Y7j1uzKbjyeEYoADx0C%2F0.png?alt=media)

### **BlocklyDuino 程式 (Light\_intensity)**

積木路徑在 **Webbit** -> **GY-30 光照度**

![](https://1275793585-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LaZQFBYOS3O0ksiEmR1%2Fuploads%2FeQUgIo1WD27mkxuv1bOu%2F1.png?alt=media)

### **Arduino 程式(Light\_intensity.ino)如下**

```
#include <Wire.h>
#include <BH1750.h>
BH1750 lightMeter;
void setup()
{
Wire.begin();
lightMeter.begin();
Serial.begin(9600);
}
void loop()
{
Serial.println((lightMeter.readLightLevel()));
delay(500);
}
```

### **程式執行結果:**

數值可從 0 到 65535 lux 的光照度。這個範圍內，0 表示完全黑暗，而 65535 lux 則表示極度強烈的光照。但在一般的環境下，數值大約是在 0 到 300 lux 左右。

![](https://1275793585-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LaZQFBYOS3O0ksiEmR1%2Fuploads%2FAK3tKXCxBXWwgff1nKyK%2F2.png?alt=media)
