How loud is our classroom? A sound graph

The micro:bit V2 logs the classroom's average and loudest sound every ten seconds for a whole lesson; learners graph it and explain the peaks.

Go to the code ↓

Lesson at a glance

45 to 60 minutes · Grades 6 to 9

maze.education/microbit/lessons/sound-graph

Grades
Grades 6 to 9
Time
45 to 60 minutes
The CAPS gives Coding and Robotics 2 hours a week (Coding and Robotics CAPS, Grades 4 to 6, page 22; Grades 7 to 9, page 22).
Level
Confident coders
For confident classes: more steps to build, with variables, radio or data.
Board
micro:bit V2 only
This lesson needs a micro:bit V2, for its microphone and data logging.
Code with
MakeCode blocks, with Python as an extension
CAPS
Natural Sciences and Technology, Natural Sciences, Mathematics, Coding and Robotics
Fits: Grade 9, Term 2 · Where it fits

Learning intentions

Learners will learn to:

  1. Plan a fair investigation into how loud a classroom gets during a lesson.
  2. Log sound data with the micro:bit V2, working out an average and a maximum for every ten seconds.
  3. Read a line graph of the data, match the peaks to what happened, and suggest ways to make the room calmer.

Success criteria

Each learner can say:

  • I can plan a fair investigation: where the logger sits, and what must stay the same.
  • I can log the average and the loudest sound for every ten seconds with the micro:bit V2.
  • I can match the peaks on our graph to what was happening, and suggest two ways to make the room calmer.
  • Grades 7 to 9: I can trace total, samples and loudest through five readings and work out the average that is logged.

Competencies

From the Coding and Robotics CAPS places this lesson cites.

  • D.1Outline the concept of technology and purpose of information technology (IT)
  • D.7Present a basic understanding of the concept of input processing and output

Key words

data logger
A device that takes readings by itself at set times and stores them for later.
average
Here the mean: add up all the readings in ten seconds and divide by how many there were.
peak
The loudest moment in a stretch of time, shown as a spike on the graph.
variable
In science, something that can change in an investigation, such as the activity in the room.
reverberation
Sound that keeps bouncing around a room after it is made, so the room sounds noisy and echoey.
trace table
A table that follows the value of each variable, step by step, as a program runs.

What you need

  • One micro:bit V2 with a battery holder for the investigation, and one for each group to build and test with
  • A computer with Chrome or Edge for each group, to open the data and draw the graph
  • A timetable of what happened in the logged lesson: silent reading, group work, a class discussion and packing up

From our shop: BBC micro:bit V2 Go, BBC micro:bit V2.21 Next Gen Classroom Pack, micro:bit Battery Box (Switched)

Safety

  • Measure everyday sound only. Never make loud noises near anyone's ears to get a high reading.
  • Logs record sound levels as numbers only, never voices or words, so nobody is recorded.
  • Use the battery holder with two AAA batteries. Never mix old and new batteries, and take the batteries out before the kits are packed away.

The lesson plan

One lesson of 45 to 60 minutes in three parts: introduction, lesson development and consolidation. The CAPS gives Coding and Robotics 2 hours a week, so it fits one of the week's lessons. Times are a guide.

  1. Introduction

    5 to 10 minutes
    Retrieval practice

    What is the mean of 4, 6 and 8, and how do you work it out? (Six: add the values to get 18, then divide by how many there are, 3.)

    Problem statement

    With forty learners in a room of brick, concrete and glass, it can be hard to hear the teacher, and the school wants evidence of when the noise builds up before it changes routines or the room. Log the classroom's sound for a whole lesson and use the graph to find the loudest times.

    1. Ask: when in a lesson is our classroom loudest? Write the class's predictions on the board.
    2. Read the problem statement together. Explain that a data logger can listen for a whole lesson while we get on with work, then show us exactly when the room was loud.
  2. Lesson development

    35 to 40 minutes
    1. Unplugged first. Be data loggers: every 30 seconds for five minutes, the teacher says 'log', and everyone writes 1 (quiet), 2 (talking) or 3 (loud) for that moment. Plot the class's numbers on the board as a rough graph, then ask what a machine could do better.
    2. Plan on paper first. Groups write the logger's algorithm. Grades 7 to 9 complete the trace table for a short test: five readings, then the row that is logged. Then groups plan the real investigation: where will the logger sit, how far from people, and what will happen in the lesson? Keep the place the same every time.
    3. Predict. Each group sketches the graph they expect for the lesson they will log, and marks where they think the peaks will be.
    4. Build in blocks. Each group has one computer and one micro:bit V2. Two learners build at a time: the driver adds the datalogger extension and builds the buttons and the forever loop from the Blocks tab; the navigator checks each block against the algorithm. Swap roles halfway, at the every 10000 ms loop, so two others take over. Download it to the micro:bit V2.
    5. Test and debug. Test it for one minute: press A, talk, clap, sit quietly, press B. Plug the board in and open MY_DATA on the MICROBIT drive. Are there five or six rows, and is the loudest in each row at least as big as the average? If the file is empty, check that the tick showed when you pressed A.
    6. Run it: place the board, press A at the start of a lesson and B at the end, and note the time of each activity. (Or use a log from an earlier lesson.)
    7. Open the data, click Visual preview to see the graph, or download it into a spreadsheet. Label each peak and dip with what was happening.

    Plan on paper: a model answer

    In groups, write the logger's algorithm and plan where it will sit and what must stay the same. Grades 7 to 9 also trace a short test of five readings.

    Algorithm
    1. Set up two columns: average and loudest.
    2. When A is pressed, set logging to true and show a tick. When B is pressed, set it to false and show a cross.
    3. Every 100 ms, if logging is true: read the sound level into level, add it to total, add 1 to samples, and if level is more than loudest, set loudest to level.
    4. Every 10 seconds, if logging is true and samples is more than 0: log the average (total ÷ samples, rounded) and loudest.
    5. Set total, samples and loudest back to 0, so the next ten seconds start fresh.
    Trace table
    Grades 7 to 9: a short test with only five readings before the row is logged. A real run takes about 100 readings in ten seconds.
    StepleveltotalsamplesloudestRow logged
    Start0000None
    Reading 14040140None
    Reading 23575240None
    Reading 3 (a clap)1201953120None
    Reading 4452404120None
    Reading 5402805120None
    10 seconds40000average 56 (280 ÷ 5), loudest 120
  3. Consolidation

    5 to 10 minutes
    1. Compare the graph with the predictions. Which activity was loudest? Was anyone surprised?
    2. Ask: why log the average and the loudest? What does each one tell us that the other does not?
    3. Back to the problem: what evidence does the graph give the school, and what could make our room calmer? Think of soft surfaces, room layout and routines. See how schools do this on our Spaces page. Learners check themselves against the success criteria.

Build it, step by step

Pairs build the program in blocks, following the numbered steps, with the same program as text beside them to check against or paste. Test in the simulator before sending it to a board.

Every 100 milliseconds the logger adds the sound level to a total and keeps the loudest; every 10 seconds it logs one row with the time, the rounded average and the loudest, then starts again.
About 100 readings become one row: the average shows the general noise and the loudest catches short peaks.

These are the MakeCode steps. The other routes are on the lesson's web page.

Build it in MakeCode blocks

  1. Start a New Project called Sound graph, and add the Data Logger extension (Extensions, then search for datalogger).
  2. In on start, add set columns from Data Logger with average and loudest.
  3. In Variables, make logging, total, samples, loudest and level. Add on button A pressed to set logging to true and show the tick; on button B pressed to set it to false and show the cross.
  4. In forever, add if logging then: set level to sound level, change total by level, change samples by 1, and if level > loudest then set loudest to level. Add pause (ms) 100.
  5. From Loops, add every 10000 ms. Inside, if logging and samples > 0 then: log data with average = round (total ÷ samples) and loudest = loudest.
  6. Still inside, set total, samples and loudest back to 0, so the next ten seconds start fresh.
  7. Download to a micro:bit V2. After logging, open MY_DATA.HTM on the MICROBIT drive.
The same blocks as text (to paste into MakeCode)
let level = 0
let loudest = 0
let samples = 0
let total = 0
let logging = false
input.onButtonPressed(Button.A, function () {
    logging = true
    basic.showIcon(IconNames.Yes)
})
input.onButtonPressed(Button.B, function () {
    logging = false
    basic.showIcon(IconNames.No)
})
loops.everyInterval(10000, function () {
    if (logging && samples > 0) {
        datalogger.log(
            datalogger.createCV("average", Math.round(total / samples)),
            datalogger.createCV("loudest", loudest)
        )
        total = 0
        samples = 0
        loudest = 0
    }
})
datalogger.setColumnTitles(
    "average",
    "loudest"
)
basic.forever(function () {
    if (logging) {
        level = input.soundLevel()
        total += level
        samples += 1
        if (level > loudest) {
            loudest = level
        }
    }
    basic.pause(100)
})

To use the text instead: open MakeCode, start a new project, click JavaScript at the top, replace what is there with this code, then click Blocks to see it as blocks.

To send it to the board, click Download. In Chrome or Edge, MakeCode can connect to the micro:bit by USB so the program goes straight onto it. Otherwise a .hex file downloads: drag it onto the MICROBIT drive.

Extension or homework

Challenges for learners who finish early, or to take further in a club or as homework.

  1. Challenge 1

    Log a different space at a quiet time, such as the hall, the library or a corridor, and compare its graph with the classroom's.

  2. Challenge 2

    Add a third column with the temperature, and see whether a full, busy room gets warmer as the lesson goes on.

  3. Challenge 3

    Hear how a room's echo changes with soft panels on our clap test page, then measure your classroom's echo time.

Support and extension

Support

For learners who need more help

  • Use a log the teacher made in an earlier lesson, and focus on reading and labelling the graph.
  • Give groups the finished program and a table to fill in: time, activity, average, loudest.

Extension

For learners who are ready for more

  • Work out the mean, median and range of the averages for each activity, and compare them in a table.
  • Log the same lesson in two places, such as the front and the back of the room, and explain any difference.

Informal assessment

Ask these as learners work. Informal assessment happens every day and is not recorded.

  1. Why does the program log an average for every ten seconds instead of one reading?
  2. Point to the loudest part of the graph. What was happening then?
  3. Name one thing that must stay the same if we compare two lessons fairly.
  4. Five readings add up to 300. What average is logged?
Exit question

Suggest two changes that could lower the averages, using the graph as evidence.

Observation checklist

Watch pairs as they plan, build and test. Write each pair's initials under the level you see.

Watch forBeginningDevelopingAccomplishedExemplary
Plans where the logger sits and what must stay the same.
Builds the logger so that it resets total, samples and loudest after each row.
Predicts the shape of the graph, then compares it with the data.
Labels peaks and dips with what was happening in the lesson.
Suggests changes that could make the room calmer, using the graph as evidence.
Beginning:
not yet, even with help
Developing:
with help
Accomplished:
on their own
Exemplary:
on their own, and explains it or takes it further

The four levels are the CAPS rubric levels (Coding and Robotics CAPS, Grades 4 to 6, page 176; Grades 7 to 9, page 163). The short descriptions are ours.

This lesson is not a formal task, but it is good practice for the term's practical task in Grades 4 to 6 (Coding and Robotics CAPS, Grades 4 to 6, page 170), and for the mini-PATs in Grades 7 to 9 (Coding and Robotics CAPS, Grades 7 to 9, page 157).

Common mistakes and fixes

  • Problem: The MY_DATA file is empty.Fix: Logging only starts after A is pressed, and the first row arrives after ten seconds. Check the tick showed.
  • Problem: Every reading is 0.Fix: You need a micro:bit V2: look for the gold logo and the microphone hole. A V1 has no microphone.
  • Problem: Old data mixes with new data.Fix: Add delete log from Data Logger to on button A+B pressed (log.delete() in Python), and press A and B together before each new investigation.

Where it sits in CAPS

  • Coding and RoboticsFitsGrade 9, Term 2: record sensor readings on the micro:bit at short intervals, then show them.Source: Coding and Robotics CAPS, Grades 7 to 9 (opens in a new tab), Grade 9, Term 2, Digital Concepts, D.7 Present a basic understanding of the concept of input processing and output, page 145: Micro: bit Application using accelerometer readings in an array (list) in short intervals.
  • Coding and RoboticsFitsGrade 7, Term 3: charts and graphs make data easier to understand.Source: Coding and Robotics CAPS, Grades 7 to 9 (opens in a new tab), Grade 7, Term 3, Digital Concepts, D.1 Outline the concept of technology and purpose of information technology (IT), page 81: IT experts create charts and graphs to help
  • MathematicsGrades 7 to 9 Mathematics: drawing graphs by hand or with technology, and interpreting them.Source: CAPS Mathematics, Grades 7 to 9 (opens in a new tab), Section 2, topic 5.2 Represent data (Grades 7, 8 and 9): Draw a variety of graphs by hand/technology to display and interpret data
  • MathematicsGrades 7 and 8 Mathematics: summarising data with the mean, median and mode, and finding the range.Source: CAPS Mathematics, Grades 7 to 9 (opens in a new tab), Section 3, topic 5.1 Collect, organize and summarize data (Grade 8): Summarize data using measures of central tendency
  • Natural SciencesFits Natural Sciences: sound, how it is made and how it reflects off hard surfaces, and planning a fair test.

Coding and Robotics quotes come from the Department of Basic Education's final CAPS, with the page number of the 2024 printed edition (the Department's October 2025 library copies number their pages differently). Schools may teach a topic in another term: the CAPS leaves the order to each school's annual teaching plan.

Ready to teach it?

Get a micro:bit for every learner or pair, and let us train your staff to run lessons like this one.

More lessons

All lessons →
  • Grades 6 to 9

    Grades 6 to 945 to 60 minLevel: Some experience

    Reaction timer

    Wait for the dot, then press A as fast as you can: learners time their reactions in milliseconds and analyse the class's data.

    Subjects: Mathematics · Coding and Robotics

    Code with: MakeCodePython

  • Grades 6 to 9

    Grades 6 to 945 to 60 minLevel: Some experience

    Plant moisture checker

    Two crocodile clip leads and a pot plant: the micro:bit measures how damp the soil is and asks for water when it is dry.

    Subjects: Natural Sciences and Technology · Technology · Natural Sciences · Coding and Robotics

    Code with: MakeCodePurple MashPython

  • Grades 6 to 9

    Grades 6 to 945 to 60 minLevel: Confident coders

    Traffic lights

    Learners program a robot (a South African traffic light) with a pedestrian button, and plan the system as a flowchart first.

    Subjects: Natural Sciences and Technology · Technology · Coding and Robotics

    Code with: MakeCodePython

micro:bit is a trade mark of the Micro:bit Educational Foundation, and BBC is a trade mark of the British Broadcasting Corporation. Maze Education is an independent reseller of genuine BBC micro:bit products. Our teacher training and our other products and services are our own, and are not endorsed by the Foundation or the BBC.

WhatsApp