小女孩的Micro:bit手表
本帖最后由 kaka_yan 于 2018-9-13 10:57 编辑Micro:bit的体积比较小,用来做穿戴就最合适了,这次小朋友尝试做一个手表,有以下功能:1、可以设定并显示时间;2、可以指示方向,箭头所指方向为北向;3、可以计步数。
零件清单如下:Microbit开发版1块、电池盒1个、5号电池2个、亚克力外壳1个、橡皮筋1盒、卡纸一张。
制作步骤:
如何显示时间?需要时钟模块吧? 程序呢,我关心程序 支持,很好看的。{:5_148:}程序+1.;P 满有爱 程序,程序,分享分享 我有java版
但只能看时间,调时间,没那么多功能
let ampm = false
let hours = 0
let adjust = 0
let time = ""
let minutes = 0
input.onButtonPressed(Button.AB, function () {
ampm = !(ampm)
})
input.onButtonPressed(Button.A, function () {
if (hours < 23) {
hours += 1
} else {
hours = 0
}
})
input.onGesture(Gesture.Shake, function () {
adjust = hours
if (ampm) {
if (hours > 12) {
adjust = hours - 12
} else {
if (hours == 0) {
adjust = 12
}
}
}
time = "" + adjust
time = "" + time + ":"
time = "" + time + minutes / 10
time = "" + time + minutes % 10
if (ampm) {
if (hours > 11) {
time = "" + time + "PM"
} else {
time = "" + time + "AM"
}
}
basic.showString(time)
})
input.onButtonPressed(Button.B, function () {
if (minutes < 59) {
minutes += 1
} else {
minutes = 0
}
})
basic.forever(function () {
basic.pause(60000)
if (hours < 59) {
minutes += 1
} else {
minutes = 0
if (hours < 23) {
hours += 1
} else {
hours = 0
}
}
}) 厉害啊 厉害
页:
[1]