/**
* init LTR390UV I2C address as 0x1C
*/
DFRobot_UVIndex240370Sensor.initLTR390UV_I2C(): void
/**
* Read ultraviolet data
* @param eType describe Data Type
*/
DFRobot_UVIndex240370Sensor.readUv(eType: eDataType): number
点击齿轮,然后点击拓展,输入URL https://github.com/cdjq/pxt-DFRobot_UVIndex240370Sensor 添加拓展。
这个拓展用到了紫外线传感器来获取数据。请确保 micro:bit
与传感器正确连接。
voltage = DFRobot_UVIndex240370Sensor.readUv(DFRobot_UVIndex240370Sensor.eDataType.OriginalData)
index = DFRobot_UVIndex240370Sensor.readUv(DFRobot_UVIndex240370Sensor.eDataType.IndexData)
level = DFRobot_UVIndex240370Sensor.readUv(DFRobot_UVIndex240370Sensor.eDataType.RiskLevelData)
- 编写测试程序
let voltage = 0
let index = 0
let level = 0
basic.forever(function () {
voltage = DFRobot_UVIndex240370Sensor.readUv(DFRobot_UVIndex240370Sensor.eDataType.OriginalData)
serial.writeNumber(voltage)
index = DFRobot_UVIndex240370Sensor.readUv(DFRobot_UVIndex240370Sensor.eDataType.IndexData)
serial.writeNumber(index)
level = DFRobot_UVIndex240370Sensor.readUv(DFRobot_UVIndex240370Sensor.eDataType.RiskLevelData)
serial.writeNumber(level)
})
- 下载到
micro:bit
中 micro:bit
通过拓展板与传感器相连,同时mocro:bit
通过USB
与电脑相连- 把传感器放在有阳光或其他发出紫外线的区域,观察串口数据打印
MIT
for PXT/microbit (The metadata above is needed for package search.)