Skip to content

Atividade

Environment exploration

Principiante | MakeCode, Python | Microfone, Sensor de luz, Sensor de temperatura | A trabalhar cientificamente, Entrada/Saída, Medições

Passo 1: Faz tu mesmo

O que é isto?

Transforma o teu BBC micro:bit numa ferramenta para medir a temperatura, a luz e os níveis de som como parte de uma investigação científica sobre o teu ambiente.

Introdução

Guia do código

Como usá-lo

  • Usa este projeto para transformar o teu micro:bit num termómetro e em medidores de som e de luz para fazer medições em experiências científicas.
  • Transfere o código em baixo para o teu micro:bit, ou assiste ao vídeo em cima se quiseres criar o teu próprio código.
  • Liga um suporte de pilhas ao teu micro:bit e estás pronto para começar.
  • Podes usar a nossa folha de registo de dados para anotar as tuas medições.

Temperatura

Use the micro:bit as a thermometer to measure differences in temperature in different places. Prime o botão A para mostrar a temperatura em graus Celsius no ecrã. 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.

Som

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).

Existe um pequeno atraso antes de ser feita a leitura do som, para garantir que o som de premir o botão não é registado.

Luz

Para usar o micro:bit como medidor de luz, prime os botões A e B ao mesmo tempo. It shows light level readings, on a scale from 0 (darkest) to 255 (lightest).

Analisa os dados

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?

Do que é que precisas

  • micro:bit
  • Editor MakeCode ou Python
  • suporte de pilhas
  • data recording sheet, or other paper
  • caneta ou lápis

Data recording sheet

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

Data recording sheet
Descarrega a tabela de registos

Passo 2: Cria o teu código

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())

Passo 3: Melhora-o

  • 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.