“数字光线”的版本间的差异

来自Labplus盛思维基百科
跳转至: 导航搜索
MicroPython示例
第28行: 第28行:
 
== 使用教程 ==
 
== 使用教程 ==
  
=== MicroPython示例 ===
+
=== <font size="3">Python示例</font> ===
 
<pre style="color:blue">
 
<pre style="color:blue">
#程序功能:用数码管显示数字光线传感器的值
 
 
from microbit import *
 
from microbit import *
 
+
import math
#@import bluebitDigitCube
+
display.off()
 
 
tm1650Init()
 
  
 
def getAmbientLight():
 
def getAmbientLight():
第42行: 第39行:
 
   t=i2c.read(0x23, 2)
 
   t=i2c.read(0x23, 2)
 
   sleep(10)
 
   sleep(10)
   return t[0]*256+t[1]
+
   return t[0]*256 + t[1]
  
 
while True:
 
while True:
  tm1650DisplayInt(getAmbientLight())
+
    print('Light:',getAmbientLight())
  sleep(500)
+
    sleep(500)
 +
 
 
</pre>
 
</pre>
  
=== 图形化示例 ===
+
=== <font size="3">图形化示例</font> ===
 
{|
 
{|
 
|-
 
|-
 
|实物连接如下图:
 
|实物连接如下图:
 
|-
 
|-
|[[文件:数字光线2.png|900px|无框|左]]
+
|[[文件:数字光线2.png|700px|无框|左]]
 
|-
 
|-
 
|程序功能:数码管显示数字光线传感器的测量值
 
|程序功能:数码管显示数字光线传感器的测量值

2018年4月25日 (三) 12:02的版本

黑色传感器最终版12.20-38.png

概述

基于BH1750数字型光照度传感器集成IC。用于检测环境光线的强度,可对广泛的亮度进行1勒克斯的高精度测定。采用I2C通讯方式,操作简便。

技术参数

  • 工作电压:VCC 3.3-5V
  • 接口方式:I2C接口
  • 光照度范围:0-65535 lx
  • 直接输出对应亮度的数字值
  • 光源依赖性弱(白炽灯,荧光灯,卤素灯,白光LED,日光灯)
  • 受红外线影响很小
  • 最小变动在±20%
  • 模块尺寸:24x46x7.5mm

引脚定义

VCC 电源
SDA I2C数据
SCL I2C时钟
GND

使用教程

Python示例

from microbit import *
import math
display.off()

def getAmbientLight():
  i2c.write(0x23, bytearray([0x10]))
  sleep(120)
  t=i2c.read(0x23, 2)
  sleep(10)
  return t[0]*256 + t[1]

while True:
    print('Light:',getAmbientLight())
    sleep(500)
  

图形化示例

实物连接如下图:
数字光线2.png
程序功能:数码管显示数字光线传感器的测量值
数字光线传感器.png

版本历史记录

Version Date Note [+]新增[-]删除[^]修复
V2.0