Skip to content

活動

Traffic survey data logger

中等級數 | MakeCode | 數據記錄 | 感應器, 數據處理, 科學化的工作方式, 統計數據和圖表, 資訊處理

步驟1:製作

它是什麼?

Use your BBC micro:bit as a data-logger to survey things you see, like different kinds of traffic or wildlife, or answers to questions.

介紹

編程指引

At the press of a button, the micro:bit records what you have seen and stores the data in a table so you can analyse it later.

Data stays on your micro:bit even if you disconnect the batteries or USB cable, so you can study it when you're back at your computer.

screenshot of traffic data logged by a micro:bit

你需要的東西

  • a micro:bit V2
  • a computer and micro USB cable for coding the micro:bit and viewing your data
  • micro:bit battery pack (optional but recommended)
  • our data logging guide may be useful

Gather data

  • Transfer the program below to your micro:bit.
  • You can record data anywhere if you unplug the micro:bit from your computer and connect a battery pack.
  • A tick appears to show it's ready to start logging.
  • Any previous data is erased when you transfer new code to your micro:bit, but you can also delete any old data by pressing buttons A and B together.
  • Press button A to record when you see a car, button B when you see a bus and press the gold touch logo when you see a truck.
    TIP: Make sure you hold your micro:bit by the edges so you don't record any data by accident.

Analyse your data

  • When you've collected your data, plug the micro:bit into a computer. The micro:bit appears like a USB drive called MICROBIT.
  • Open the MY_DATA file to see a table of all the traffic you recorded in your web browser:
The MICROBIT drive as it appears in Windows
The MY_DATA file as it appears when you open it in a web browser
  • The times recorded in the table show the amount of time that passed since your micro:bit was powered on.

You can:

  • Add up the total of each column to make your own column or bar chart to visualise your survey data.
  • Press the copy button to copy the data so you can paste it straight into a spreadsheet. Use the spreadsheet's sum function to count the total number of each kind of vehicle.
  • Download the data as a CSV (comma separated values) file which you can also import into a spreadsheet.
traffic data recorded on a micro:bit pasted into an Excel spreadsheet

步驟2:編碼

步驟3:進階

  • Remix the code to count different things:
    • different kinds of wildlife in your area
    • do a litter patrol to count recycling, compost and normal rubbish
    • carry out a survey of how people get to school, for example, walk, bus or bike
    • survey people's votes for choices of activities
  • Analyse your data, write up your findings and present it back to people in your area. Can you motivate them to change behaviour around modes of transport or recycling litter?