sparkfun的microbit温度计

micro:bit编程、教学、展示
STEM
回复
头像
shaoziyang
帖子: 3917
注册时间: 2019年 10月 21日 13:48

sparkfun的microbit温度计

#1

帖子 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))
})

回复

  • 随机主题
    回复总数
    阅读次数
    最新文章