BBC micro:bit|SCIENCE|物质的转换

2019-01-296640
精华项目
AI 快速预览详细 收起
本文介绍了如何使用BBC micro:bit进行物质状态转换实验。项目大约需要30-45分钟,适合STEM教育场景。通过简单的材料如纸板、铝箔和鳄鱼夹,结合micro:bit的编程功能,可以制作一个湿度和温度探测器。项目步骤包括变量设置、检测固体、液体和气体状态,以及显示温度变化。这个实验不仅帮助孩子理解物质状态变化的原理,还能激发他们的科学兴趣。
micro:bit/ SCIENCE/ 物质的转换
本文转自micro:bit官方网站
翻译kiki 未经许可请勿转载
BBC micro:bit|SCIENCE|物质的转换图8
所需时间:
基于对编码概念的熟悉程度,该项目大约需要30-45分钟

物料:
* 纸板
* 铝箔
* 标记笔(红色和黑色)
* 1个micro:bit电池座和2节AAA电池
* 4个鳄鱼夹
不好意思 又要看视频广告了


步骤:
将一块纸板变成湿度和温度的探测器!
* 折叠铝箔纸块,并将它们放在纸板周围。
* 将每片箔连接到micro:bit上的相应引脚。
而已!

代码:
你有没有试过代表物质的状态?让我们尝试在视觉上代表基于大气温度的各种物质状态

第1步:变量

为了使物质遵循大气温度的规则,我们需要添加存储数据的变量。然后我们将分配(设置)变量的值。
我们想要将两(2)个变量命名如下:“atmos_temperature”和“temperature”。将变量的值设置为100.修改代码,使其看起来像这样。
BBC micro:bit|SCIENCE|物质的转换图1
[mw_shl_code=applescript,true]let temperature = 100
let atmos_temperature = 100[/mw_shl_code]

第2步:检测固体
BBC micro:bit|SCIENCE|物质的转换图2
BBC micro:bit|SCIENCE|物质的转换图9

[mw_shl_code=applescript,true]let temperature = 0
let atmos_temperature = 0
input.onPinPressed(TouchPin.P2, () => {
    atmos_temperature = 0
    basic.showString("SOLID")
})
atmos_temperature = 100
temperature = 100[/mw_shl_code]

第3步:检测液体
BBC micro:bit|SCIENCE|物质的转换图3
BBC micro:bit|SCIENCE|物质的转换图10
[mw_shl_code=applescript,true]let temperature = 0
let atmos_temperature = 0
input.onPinPressed(TouchPin.P2, () => {
    atmos_temperature = 0
    basic.showString("SOLID")
})
input.onPinPressed(TouchPin.P1, () => {
    atmos_temperature = 80
    basic.showString("LIQUID")
})
atmos_temperature = 100
temperature = 100[/mw_shl_code]

第4步:检测气体
BBC micro:bit|SCIENCE|物质的转换图4
BBC micro:bit|SCIENCE|物质的转换图11
[mw_shl_code=applescript,true]let atmos_temperature = 0
let temperature = 0
input.onPinPressed(TouchPin.P0, () => {
    atmos_temperature = 250
    basic.showString("GAS")
})
input.onPinPressed(TouchPin.P2, () => {
    atmos_temperature = 0
    basic.showString("SOLID")
})
input.onPinPressed(TouchPin.P1, () => {
    atmos_temperature = 80
    basic.showString("LIQUID")
})
atmos_temperature = 100
temperature = 100[/mw_shl_code]

第5步:提高温度
BBC micro:bit|SCIENCE|物质的转换图5
[mw_shl_code=applescript,true]let atmos_temperature = 0
let temperature = 0
input.onGesture(Gesture.Shake, () => {
    temperature += 50
    basic.showIcon(IconNames.Triangle)
})
input.onPinPressed(TouchPin.P0, () => {
    atmos_temperature = 250
    basic.showString("GAS")
})
input.onPinPressed(TouchPin.P2, () => {
    atmos_temperature = 0
    basic.showString("SOLID")
})
input.onPinPressed(TouchPin.P1, () => {
    atmos_temperature = 80
    basic.showString("LIQUID")
})
atmos_temperature = 100
temperature = 100[/mw_shl_code]

第6步:显示温度变化
BBC micro:bit|SCIENCE|物质的转换图6

BBC micro:bit|SCIENCE|物质的转换图7
[mw_shl_code=applescript,true]let atmos_temperature = 0
let temperature = 0
input.onGesture(Gesture.Shake, () => {
    temperature += 50
    basic.showIcon(IconNames.Triangle)
})
basic.forever(() => {
    if (temperature < atmos_temperature) {
        temperature += 20
    } else {
        temperature += -20
    }
    if (temperature < 32) {
        basic.showIcon(IconNames.Square)
    } else if (temperature < 212) {
        basic.showIcon(IconNames.Umbrella)
    } else {
        basic.showIcon(IconNames.Chessboard)
    }
    basic.clearScreen()
    basic.pause(100)
})
input.onPinPressed(TouchPin.P0, () => {
    atmos_temperature = 250
    basic.showString("GAS")
})
input.onPinPressed(TouchPin.P2, () => {
    atmos_temperature = 0
    basic.showString("SOLID")
})
input.onPinPressed(TouchPin.P1, () => {
    atmos_temperature = 80
    basic.showString("LIQUID")
})
atmos_temperature = 100
temperature = 100[/mw_shl_code]


创作许可协议

本项目采用 None(不开放任何权利,保留所有权利) 进行许可。

评论(1)
gada888
gada888
有趣
- 没有更多了 -