1 Star 0 Fork 0

DFRobot/pxt-DFRobot_bosonKit

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
test.ts 1.78 KB
一键复制 编辑 原始数据 按行查看 历史
zhang-tang 提交于 2022-10-26 16:15 . 更新 bosonKit.ts, test.ts
input.onButtonPressed(Button.A, function () {
count = count + 1
if (count == 1) {
bosonKit.m01100184SetIndexColor(1, 0xff0000)
bosonKit.m01100184SetIndexColor(2, bosonKit.m01100184Rgb(33, 132, 29))
bosonKit.m01100184SetIndexColor(bosonKit.m01100184LedRange(3, 4), 0x0000ff)
bosonKit.m01100184SetIndexColor(5, 0xffff00)
} else if (count == 2) {
bosonKit.m01100184LedRainbow(1, 5, 1, 360)
} else if (count > 2) {
count = 0
bosonKit.m01100184Off()
}
})
input.onButtonPressed(Button.B, function () {
count = 3
})
let count = 0
bosonKit.m01100184Init(DigitalPin.P0, 5)
bosonKit.heartrateInit(DigitalPin.P1)
bosonKit.m01100184Brightness(255)
count = 0
basic.forever(function () {
serial.writeLine("Press the A key: RGB light display (P0)")
serial.writeLine("Press the B key: RGB light is turned off, obtain the heart rate value")
serial.writeLine("count:" + count)
serial.writeLine("analog write P2:")
bosonKit.bosonAnalogWrite(AnalogPin.P2, 0, bosonKit.BosonSensorAnalogWrite.BosonBrightLightLed)
serial.writeLine("analog read P3:" + bosonKit.bosonAnalogRead(AnalogPin.P3, bosonKit.BosonSensorAnalogRead.BosonRotation))
serial.writeLine("digital write P4:")
bosonKit.bosonDigitalWrite(DigitalPin.P4, 0, bosonKit.BosonSensorDigitalWrite.BosonBrightLightLed)
serial.writeLine("digital read P5:" + bosonKit.bosonDigitalRead(DigitalPin.P5, bosonKit.BosonSensorDigitalRead.BosonPushButton))
bosonKit.setServoAngle(AnalogPin.P10, 0)
if (count == 1) {
bosonKit.m01100184Shift(1)
} else if (count == 2) {
bosonKit.m01100184Rotate(1)
} else if (count == 3) {
bosonKit.m01100184Off()
serial.writeLine("heart rate P1:" + bosonKit.heartrateRead())
}
basic.pause(1000)
})
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/dfrobot/pxt-DFRobot_bosonKit.git
git@gitee.com:dfrobot/pxt-DFRobot_bosonKit.git
dfrobot
pxt-DFRobot_bosonKit
pxt-DFRobot_bosonKit
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385