分页: 1 / 1

sparkfun的microbit温度计

发表于 : 2019年 11月 8日 20:54
shaoziyang
来自:https://www.sparkfun.com/news/2367

使用microbit控制舵机显示温度

代码: 全选

let temperature = 0
basic.forever(function () {
    temperature = input.temperature()
    if (temperature < 20) {
        temperature = 20
    } else if (temperature > 35) {
        temperature = 35
    }
    pins.servoWritePin(AnalogPin.P0, Math.map(temperature, 20, 35, 0, 180))
})