查看“数字光线”的源代码
←
数字光线
跳转至:
导航
,
搜索
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于这些用户组的用户使用:
用户
,labplus
您可以查看与复制此页面的源代码。
[[文件:黑色传感器最终版12.20-38.png|350px|thumb|right]] == 概述 == 基于BH1750数字型光照度传感器集成IC。用于检测环境光线的强度,可对广泛的亮度进行1勒克斯的高精度测定。采用I2C通讯方式,操作简便。 == 技术参数 == * 工作电压:VCC 3.3-5V * 接口方式:I2C接口 * 光照度范围:0-65535 lux * 直接输出对应亮度的数字值 * 光源依赖性弱(白炽灯,荧光灯,卤素灯,白光LED,日光灯) * 受红外线影响很小 * 最小变动在±20% * 模块尺寸:24x46x7.5mm == 引脚定义 == {| class="wikitable" |- | <small>VCC</small> || <small>电源</small> |- | <small>SDA</small> || <small>I2C数据</small> |- | <small>SCL</small> || <small>I2C时钟</small> |- | <small>GND</small> || <small>地</small> |} == 使用教程 == <font size="3.5">BH1750FVI支持单次或连续两种测量模式,每种测量模式又提供了0.5lux、1lux、4lux三种分辨率供选择。分辨力越高,一次测量所需的时间就越长。在单次测量模式时,每次测量之后传感器都自动进入Power Down模式。</font> {| |- | :[[文件:BH1750测量模式.png|800px|左|缩略图|BH1750测量模式]] |} === <font size="3">Arduino示例</font> === <pre style="color:blue"> /* Measurement of illuminance using the BH1750FVI sensor module Connection: Module UNO VCC <-----> 5V GND <-----> GND SCL <-----> A5 SDA <-----> A4 */ #include <Wire.h> #define ADDRESS_BH1750FVI 0x23 //ADDR="L" for this module #define H_RESOLUTION_MODE 0x10 //continuously H-Resolution Mode: //Resolution = 1 lux //Measurement time (max.) = 120ms //Power down after each measurement byte highByte = 0; byte lowByte = 0; unsigned int sensorOut = 0; unsigned int illuminance = 0; void setup() { Wire.begin(); Serial.begin(115200); } void loop() { Wire.beginTransmission(ADDRESS_BH1750FVI); //"notify" the matching device Wire.write(H_RESOLUTION_MODE); //set operation mode Wire.endTransmission(); delay(120); Wire.requestFrom(ADDRESS_BH1750FVI, 2); //ask Arduino to read back 2 bytes from the sensor highByte = Wire.read(); // get the high byte lowByte = Wire.read(); // get the low byte sensorOut = (highByte << 8) | lowByte; illuminance = sensorOut / 1.2; Serial.print(illuminance); Serial.println(" lux"); delay(1000); } </pre> === <font size="3">Python示例</font> === <pre style="color:blue"> 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])/1.2 while True: print('Light:',getAmbientLight()) sleep(500) </pre> === <font size="3">图形化示例</font> === {| |- |实物连接如下图: |- |[[文件:数字光线2.png|700px|无框|左]] |- |程序功能:数码管显示数字光线传感器的测量值 |- | [[文件:数字光线传感器.png|900px|无框|左]] |- |} == 版本历史记录 == {| border="1" cellspacing="0" align="left" cellpadding="0" width="60%" style="text-align:center;" |- style="text-align:center;background-color:#6fa8dc;color:#fffff;" !width="10%"|Version !!width="15%"| Date !! Note <small>[+]新增[-]删除[^]修复</small> |- | V2.0 || || style="text-align:left"| |}
返回至
数字光线
。
导航菜单
个人工具
登录
命名空间
页面
讨论
变种
视图
阅读
查看源代码
查看历史
更多
搜索
导航
首页
软件
Labplus软件
mPython软件
Mixly集成盛思版
mpython_conn
教学套件
创客初级实验箱
创客初级实验箱进阶版
创客中级实验箱
创客中级实验箱Ⅱ
人工智能交互实验箱
桌面机器人
乐动魔盒
可穿戴作品电子套件
创意触摸板套装
乐动魔块中级套装
乐动魔块高级套装
bot:bit
编程造物套装
逻辑造物套装
人工智能套装
物联网套装
高中信息技术套装
掌控板初级套装
初中信息技术材料包
开源硬件教学套装
冲锋舟
造物
Arduino
乐动魔块(旧版)
Blue:bit电子积木
MicroBit系列
掌控板系列
AI摄像头V1.0
AI摄像头V2.0
1956
掌控魔盒
乐动掌控
乐动魔块
互动作品
森林奇遇记
创客森林
创客乐园
物联网演示系统
博物馆防盗演示实验系统
梦想舞台演示实验系统
智能家居演示实验系统
智能教室演示实验系统
智能停车场演示实验系统
DIY-木板系列
嘘寒问暖
硬币存款机
吼一声试试
斜不胜正灯
时光葫芦
旋转转盘
越光宝盒
治愈系萌犬
光明使者
避障机械车
DIY-亚克力系列
情绪机器人
创意七彩灯
温湿度机器人
留言机
游龙戏灯
三色时钟
光影精灵
光影时钟
智能应用系列
LED眼镜
32x16 RGB LED点阵屏
DIY环境温湿度显示系统
DIY创客空间访客记录仪
其他
金属结构件套装
耗材存取管理柜
更多
课程资源
常见问题解答
Arduino语法参考手册
链接
Labplus官网
STEAM创客教育平台
工具
链入页面
相关更改
特殊页面
页面信息