小女孩的Micro:bit手表
2018-09-131.1万
AI 快速预览详细
这款Micro:bit手表项目适合8-12岁的孩子,通过简单的步骤,孩子们可以制作一个多功能手表。硬件清单包括Microbit开发版、电池盒、5号电池、亚克力外壳、橡皮筋和卡纸。最终效果包括时间显示、指南针和计步功能。这个项目不仅能够提升孩子的动手能力,还能培养他们的逻辑思维。
|
micro:bit的体积比较小,用来做穿戴就最合适了,这次小朋友尝试做一个手表,有以下功能:1、可以设定并显示时间;2、可以指示方向,箭头所指方向为北向;3、可以计步数。 ![]() 零件清单如下:Microbit开发版1块、电池盒1个、5号电池2个、亚克力外壳1个、橡皮筋1盒、卡纸一张。 ![]() 制作步骤: ![]() ![]() ![]() ![]() ![]() ![]() ![]() |














但只能看时间,调时间,没那么多功能
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
}
}
})