“数字光线”的版本间的差异
来自Labplus盛思维基百科
Tangliufeng(讨论 | 贡献) |
Labplus课程组(讨论 | 贡献) (→MicroPython示例) |
||
第32行: | 第32行: | ||
=== MicroPython示例 === | === MicroPython示例 === | ||
<pre style="color:blue"> | <pre style="color:blue"> | ||
+ | //程序功能:用数码管显示数字光线传感器的值// | ||
from microbit import * | from microbit import * | ||
− | import | + | |
− | + | #@import bluebitDigitCube | |
+ | |||
+ | tm1650Init() | ||
def getAmbientLight(): | def getAmbientLight(): | ||
第41行: | 第44行: | ||
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()) | |
− | |||
− | |||
</pre> | </pre> | ||
2018年4月20日 (五) 15:22的版本
概述
基于BH1750数字型光照度传感器集成IC。用于检测环境光线的强度,可对广泛的亮度进行1勒克斯的高精度测定。采用I2C通讯方式,操作简便。
技术参数
- 工作电压:VCC 3.3-5V
- 接口方式:I2C接口
- 光照度范围:0-65535 lx
- 直接输出对应亮度的数字值
- 光源依赖性弱(白炽灯,荧光灯,卤素灯,白光LED,日光灯)
- 受红外线影响很小
- 最小变动在±20%
- 模块尺寸:24x46x7.5mm
引脚定义
VCC | 电源 |
SDA | I2C数据 |
SCL | I2C时钟 |
GND | 地 |
使用教程
连接示意图
Arduino示例
MicroPython示例
//程序功能:用数码管显示数字光线传感器的值// from microbit import * #@import bluebitDigitCube tm1650Init() def getAmbientLight(): i2c.write(0x23, bytearray([0x10])) sleep(120) t=i2c.read(0x23, 2) sleep(10) return t[0]*256+t[1] while True: tm1650DisplayInt(getAmbientLight())
图形化示例
版本历史记录
Version | Date | Note [+]新增[-]删除[^]修复 |
---|---|---|
V2.0 |