Skip to content

アクティビティ

環境調査

初級 | MakeCode, Python | マイク, 光センサー, 温度センサー | 入出力, 科学的に働く, 計測

ステップ1: 作る

説明

BBC micro:bitを環境科学調査の一環として、温度、光、音量を測定するツールに変えましょう。

はじめに

プログラミングガイド

使い方

  • Use this project to turn your micro:bit into a thermometer, and sound and light meters for taking measurements in science experiments.
  • 以下のコードをmicro:bitに転送するか、自分でプログラムを作成したい場合は上記のコーディングビデオを見てください。
  • 電池ボックスをmicro:bitに取り付ければ準備完了です。
  • 測定値を記録するために、私たちが用意したデータ記録シートを使用できます。

温度

Use the micro:bit as a thermometer to measure differences in temperature in different places. Press button A to show the temperature in degrees Celsius on the display. It’s a good idea to leave the micro:bit in a new location for a couple of minutes to ensure you get an accurate reading.

To use the micro:bit as sound level meter, press button B to show the sound level on a scale from 0 (quietest) to 255 (loudest).

There’s a short delay before it takes the sound reading to make sure the sound of pressing the button isn’t recorded.

To use the micro:bit as a light meter, press buttons A and B together. It shows light level readings, on a scale from 0 (darkest) to 255 (lightest).

データの分析

Top tip: gathering as much data as you can is good scientific practice, so you might want to take several readings in each location and calculate an average.

Once you’ve recorded your data you can analyse it to draw conclusions. What is there to learn from your data about temperature, sound and light levels around you?

Where was warmest, coolest, loudest, quietest, lightest, or darkest and what factors may have affected this?

必要なもの

  • micro:bit
  • MakeCodeまたはPythonエディター
  • 電池ボックス
  • データ記録用紙などの紙
  • ペンか鉛筆

データ記録シート

The data recording sheet can be used to record your measurements.

Data recording sheet
Download the recording sheet

ステップ2: プログラムする

1from microbit import *
2
3# The Python version of this project has sleep()
4# for each button press to make the A+B button work better
5
6while True:
7    if button_a.is_pressed() and button_b.is_pressed():
8        display.scroll(display.read_light_level())
9        sleep(200)
10    elif button_a.is_pressed():
11        display.scroll(temperature())
12        sleep(200)
13    elif button_b.is_pressed():
14        sleep(200)
15        display.scroll(microphone.sound_level())

ステップ3: 改善する

  • Add ‘show string’ blocks to make it clearer when temperature, sound and light readings are being displayed.
  • You can modify the code to show temperature readings in Fahrenheit – see our Fahrenheit thermometer project for tips on how to do this.
  • If you have the micro:bit V1, which doesn’t have a microphone, you can remove the code for button B and just take temperature and light level measurements.