代码拉取完成,页面将自动刷新
basic.forever(function () {
serial.writeValue("rotation:", bosonKit.bosonAnalogRead(AnalogPin.P0, bosonKit.BosonSensorAnalogRead.BosonRotation))
})
basic.forever(function () {
serial.writeValue("light_intensity:", bosonKit.bosonAnalogRead(AnalogPin.P0, bosonKit.BosonSensorAnalogRead.BosonLightIntensity))
basic.pause(1000)
})
basic.forever(function () {
serial.writeValue("steam:", bosonKit.bosonAnalogRead(AnalogPin.P0, bosonKit.BosonSensorAnalogRead.BosonSteam))
basic.pause(1000)
})
basic.forever(function () {
serial.writeValue("flame:", bosonKit.bosonAnalogRead(AnalogPin.P0, bosonKit.BosonSensorAnalogRead.BosonFlame))
basic.pause(1000)
})
basic.forever(function () {
serial.writeValue("sound:", bosonKit.bosonAnalogRead(AnalogPin.P0, bosonKit.BosonSensorAnalogRead.BosonSound))
basic.pause(1000)
})
basic.forever(function () {
serial.writeValue("grayscale:", bosonKit.bosonAnalogRead(AnalogPin.P0, bosonKit.BosonSensorAnalogRead.BosonGrayscale))
serial.writeValue("temp:", bosonKit.bosonAnalogRead(AnalogPin.P1, bosonKit.BosonSensorAnalogRead.BosonTemperature))
serial.writeValue("soil:", bosonKit.bosonAnalogRead(AnalogPin.P2, bosonKit.BosonSensorAnalogRead.BosonSoilMoisture))
serial.writeValue("humidity:", bosonKit.bosonAnalogRead(AnalogPin.P3, bosonKit.BosonSensorAnalogRead.BosonHumidity))
basic.pause(1000)
})
The method above is also applicable to other analog sensors.
basic.forever(function () {
serial.writeValue("button", bosonKit.bosonDigitalRead(DigitalPin.P0, bosonKit.BosonSensorDigitalRead.BosonPushButton))
})
basic.forever(function () {
bosonKit.bosonDigitalWrite(DigitalPin.P1, 1, bosonKit.BosonSensorDigitalWrite.BosoFan)
})
basic.forever(function () {
if (bosonKit.bosonDigitalRead(DigitalPin.P0, bosonKit.BosonSensorDigitalRead.BosonPushButton) == 1) {
bosonKit.bosonDigitalWrite(DigitalPin.P1, 1, bosonKit.BosonSensorDigitalWrite.BosonBrightLightLed)
} else {
bosonKit.bosonDigitalWrite(DigitalPin.P1, 0, bosonKit.BosonSensorDigitalWrite.BosonBrightLightLed)
}
})
basic.forever(function () {
bosonKit.bosonAnalogWrite(AnalogPin.P0, 429, bosonKit.BosonSensorAnalogWrite.BosonFan)
})
basic.forever(function () {
bosonKit.bosonAnalogWrite(AnalogPin.P8, Math.map(bosonKit.bosonAnalogRead(AnalogPin.P0, bosonKit.BosonSensorAnalogRead.BosonRotation), 0, 1023, 0, 1023), bosonKit.BosonSensorAnalogWrite.BosonBrightLightLed)
})
bosonKit.heartrateInit(DigitalPin.P0)
basic.forever(function () {
serial.writeValue("heartrate:", bosonKit.heartrateRead())
})
bosonKit.m01100184Init(DigitalPin.P0, 7)
bosonKit.m01100184ShowColor(0xff0000)
basic.pause(5000)
bosonKit.m01100184Off()
bosonKit.m01100184Init(DigitalPin.P0, 7)
basic.forever(function () {
bosonKit.m01100184SetIndexColor(bosonKit.m01100184LedRange(1, 2), 0xff0000)
bosonKit.m01100184SetIndexColor(bosonKit.m01100184LedRange(3, 4), 0x00ff00)
bosonKit.m01100184SetIndexColor(bosonKit.m01100184LedRange(5, 7), 0x0000ff)
})
bosonKit.m01100184Init(DigitalPin.P0, 7)
bosonKit.m01100184Brightness(50)
basic.forever(function () {
bosonKit.m01100184ShowColor(0xff0000)
})
bosonKit.setServoAngle(AnalogPin.P0, 0)
basic.forever(function () {
bosonKit.setServoAngle(AnalogPin.P0, 90)
})
MIT
Copyright (c) 2020, microbit/micropython Chinese community
bosonKit=github:DFRobot/pxt-DFRobot_Boson_Kit
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。