Jump to main content

Program a Sound Level Meter to Help Protect Your Hearing

Abstract

Have you ever said, "That hurt my ears!" when someone yelled loudly right next to you? Do you cover your ears when a fire truck drives by with the sirens blaring? It is good to protect your ears—even sounds that do not "hurt" can cause hearing damage if you are exposed to them for too long. In this project, you will program a device that alerts you when sounds have exceeded safe levels long enough to cause hearing damage.

Summary

Areas of Science
Difficulty
Method
Time Required
Short (2-5 days)
Prerequisites

None

Material Availability

This project requires a micro:bit, available from our partner Home Science Tools®

Cost
Low ($20 - $50)
Safety

Prolonged exposure to sounds over 70 dB can cause hearing damage. Wear ear protection if testing your device with sounds louder than 70 dB. 

Credits
Science Buddies is committed to creating content authored by scientists and educators. Learn more about our process and how we use AI.

Objective

Program a device to alert you when sounds have exceeded safe levels for too long.

Introduction

Have you ever wondered how we measure the loudness of a sound? We measure sound in units called decibels (dB). The decibel scale is logarithmic, not linear. For every increase of 10 dB, a sound is perceived as roughly twice as loud. For example, a quiet place like a library typically has a sound level of 40 dB. Normal human conversation is about 60 dB, which means it sounds about four times as loud as a library. Figure 1 shows some decibel levels of common sounds.

chart showing decibel levels of common soundsImage Credit: Ben Finio / Science Buddies

threshold of hearing 0, normal breathing 10, rustling leaves 20, whisper 30, library 40, moderate rainfall 50, normal conversation 60, city traffic 70, screaming baby 80, lawn mower 90, chainsaw 100, car horn 110, live rock concert 120, jet engine 130, gunshot 140

Figure 1. Decibel levels of common sounds.

Sounds below 70 dB are generally considered safe, but sounds louder than that can damage your hearing over time, for example, over the course of a school or work day. Very loud sounds, like those from chainsaws and jet engines, can cause hearing damage in shorter periods of time. That is why it is very important for people who work around loud equipment and machinery to wear ear protection. Even if you do not work directly near loud equipment, you can still be exposed to loud background noise, or noise pollution, like noise from a highway or city traffic. 

It might seem obvious that some sounds are so loud that they hurt your ears, but what about longer-term exposure to sounds right around 70 dB? It might not hurt your ears, and you might not realize you are at risk of hearing damage. A sound-monitoring device can help in situations like this. The device can continuously monitor decibel levels and keep track of your sound exposure throughout the day. If sound levels exceed a certain threshold for too long, the device can alert you. This can help you evaluate what actions you can take to reduce your risk of hearing loss—like moving farther away from the source of a loud noise, wearing ear protection, or taking breaks to let your ears rest. 

In this project, you will use a small programmable device called a micro:bit to make your own sound-monitoring device. You can customize the program, so the exact thresholds to trigger the alarm and how it sends alerts are up to you!

Terms and Concepts

Questions

Bibliography

Materials and Equipment

Experimental Procedure

This project follows the Engineering Design Process. Confirm with your teacher if this is acceptable for your project, and review the steps before you begin.
  1. If you have never used a micro:bit before, watch our micro:bit setup video before you continue. 
  2. This is an engineering design project. There is no single "correct" way to write your program. We will provide some simple examples, but you can modify or add to them. Think about the criteria you want to establish for your project.
    1. Do you want your device to alert the user if instantaneous sound levels exceed a certain threshold?
    2. Do you want to alert the user if cumulative sound levels have stayed above a certain level for a certain amount of time?
    3. Do you want your device to have a combination of these features, monitoring both instantaneous and cumulative levels?
    4. How will the device alert the user? What outputs are available on the micro:bit that you could use?
    5. How will your user interact with the device? What inputs are available on the micro:bit that you could use?
  3. Start a new program in MakeCode. 
    1. Click on Extensions in the blocks menu.
    2. Search for "sound level decibels" and import the sound-level-db extension.
    3. This extension adds a block that displays the measured sound level in decibels, instead of the 0-255 range shown by the normal sound level block.
  4. First, you will make a basic decibel meter that displays the current sound level in decibels on the micro:bit's LED display. Write the program shown in Figure 2.
    1. Place a show number block from the Basic menu inside your forever loop.
    2. Place a sound level (dB) block from the Input menu inside your show number block.
Figure 2. Code to display sound level.
  1. Connect your micro:bit to battery power and carry it around. Measure background sound levels in different locations, like different rooms of your home or outside. 
    1. The microphone used to measure sound is on the back of the micro:bit board. Make sure you do not cover the microphone when holding the micro:bit because this could affect the sound levels. 
  2. Try measuring decibel levels of different continuous sounds, like a fan or humming. Since it takes a while for each decibel reading to scroll across the screen, this program will not work well for measuring quick sounds like clapping. 
    1. If you decide to test something loud (like a lawnmower), wear ear protection.
    2. How does the sound level change as you move closer to or farther away from the sound source?
  3. Write a new program like the one in Figure 3. This program displays a smiley face when the sound level is below a certain threshold and switches to a frowny face when sound levels meet or exceed that threshold.
    1. Add an if else statement from the Logic menu inside your forever loop.
    2. Put a comparison block from the Logic menu inside the condition for the if else statement.
    3. Put a sound level (dB) block from the Input menu in the first value of the comparison block.
    4. Enter a number (in decibels) for the other value in the comparison block. The example in Figure 3 shows a value of 60, but you can choose a different number.
    5. Optional: change the comparison operator to a less than (<) symbol, depending on how you want your if else statement to behave.
    6. Put a show icon :) block in the if part of the if else statement.
    7. Put a show icon :( block in the else part of the if else statement.
Figure 3. Program for a basic sound level alarm.
  1. Download the new program to your micro:bit and connect it to battery power. Carry it around (again, being careful not to cover the microphone) and test it with all the same locations and sounds you tested earlier. 
    1. Does the program reliably switch to the frowny face when exposed to loud sounds?
    2. The code in the forever loop takes some time to run. Does the program work for quick sounds like claps, or does it miss some of them? Does it work well for more continuous sounds?
    3. Optionally, you can try writing a program using the on loud sound event block (from the Input menu) instead of a forever loop with an if else statement. You can adjust the loud sound threshold using the set loud sound threshold to block, also from the Input menu. Does this program do a better job monitoring for quick loud sounds?
  2. So far, the two programs you have written only react to instantaneous sound levels. What if you want to measure exposure to sound levels above a certain threshold over time? Figure 4 shows one way you could do that. Remember that this is an engineering design project, so you do not have to do exactly what is shown in Figure 4. Here is how the program works conceptually:
    1. When the program starts: 
      1. It sets a variable called seconds to zero. This variable will count the total time (in seconds) the user has been exposed to sound above a certain threshold.
      2. The program also sets variables called sound_threshold, the decibel level considered unsafe for extended periods of time, and time_threshold, the total amount of allowed exposure time. You can choose these values.
      3. It shows a smiley face on the screen.
    2. Then, once every second (1,000 milliseconds):
      1. The program checks if the current sound level (dB) is greater than the sound_threshold value.
      2. If so, then it increases the seconds variable by 1.
      3. It checks if the current seconds value is greater than the time_threshold value.
      4. If so, it switches the display to a frowny face, indicating that the user has exceeded safe levels of total noise exposure. 
Figure 4. Program to react to cumulative sound exposure over time.
  1. Here are instructions to write the program:
    1. To make a variable, click the Variables menu, then click Make a Variable. Create three variables. Step 9 and Figure 4 have example names, but you can use other names if you want. Just make sure the names make sense to you.
    2. For each variable, add a set (variable name) to block to the on start block.
      1. Leave the seconds variable set to 0.
      2. Select a sound threshold value. To make it easier to test your code without requiring extremely loud sounds, you may want to set a value around 50 or 60 dB.
      3. Select a time threshold value in seconds. To make it easier to test your project without waiting for long periods of time, you might want to pick a short time threshold at first, like 5 or 10 seconds. 
    3. Put a show icon :) block in the on start block.
    4. Add an every 500 ms block from the Loops menu to your program.
    5. Change the time to 1000 ms.
    6. Add an if statement (not an if else statement) inside your every 1000 ms block.
    7. Add blocks to make the condition of the if statement sound level (dB) > sound_threshold (or whatever you named the variable).
    8. Put a change seconds by 1 block inside the if statement.
    9. Add a second if statement inside the every 1000 ms block. Make sure it comes after the first if statement, not nested inside it.
    10. Make the condition of the second if statement seconds > time_threshold (again, your variable names may be different).
    11. Add a show icon :( block inside the second if statement.
  2. Download the new program to your micro:bit and test it.
    1. If you set low enough sound and time thresholds, you can test it quickly just by talking or humming, without requiring any other sources of sound.
    2. Does the program work as expected? In other words, does it start out showing a smiley face and switch to a frowny face after a loud sound has gone on for too long? 
    3. Set higher values for the sound and time thresholds. Keep the micro:bit with you as you go about an activity (remember to wear hearing protection if needed). How long does it take for the "alarm" to trigger? Do you think you would have noticed the sound levels on your own, without help from the micro:bit?
  3. If you plan to enter this project in a science or engineering fair, you should make your own changes to the program, not just copy the program in Figure 4. Go back to the criteria you set in step 2. Does the current program meet all of your criteria? If not, what could you add or change? See the Variations section for more ideas.
icon scientific method

Ask an Expert

Do you have specific questions about your science project? Our team of volunteer scientists can help. Our Experts won't do the work for you, but they will make suggestions, offer guidance, and help you troubleshoot.

Global Goals

The United Nations Sustainable Development Goals (UNSDGs) are a blueprint to achieve a better and more sustainable future for all.

This project explores topics key to Good Health and Well-Being: Ensure healthy lives and promote well-being for all at all ages.

Variations

  • The example programs use the micro:bit's LED display to show smiley or frowny faces. Can you use other outputs, like showing a message on the screen? What about playing a sound with the micro:bit's built-in speaker? Is the sound loud enough for you to hear it if you are already in a loud room? What about sending a radio message to another micro:bit?
  • Can you add a way for the user to interact with your program? For example, there is no way to reset the program in Figure 4 and start the timer over without resetting the micro:bit. Can you use a button press (or other input) to reset the seconds variable to zero?
  • Can you make the timer automatically reset if decibel readings have stayed within a safe level for a certain amount of time? Does it make sense to do that based on guidelines about hearing protection?
  • Do some research about safe exposure limits for sounds at different decibel levels. Can you write a program that will trigger an alarm if exposure limits are exceeded for any of multiple decibel/time combinations? For example, 8 hours of sound at 70 dB or 4 hours of sound at 80 dB?
  • It might be inconvenient to carry a micro:bit around all day. Can you design or build something so a person can easily wear a micro:bit attached to their clothing? Remember to make sure the microphone on the back of the micro:bit is not covered when the person wears it. 

Careers

If you like this project, you might enjoy exploring these related careers:

Career Profile
On each side of your head is the auditory system, one of the most beautifully designed organs in the human body. The auditory system not only detects sound, but is closely tied to the vestibular system, which helps a person with balance, and knowing how his or her body is moving through space. Audiologists detect, diagnose, and develop treatment plans for people of all ages who have problems with hearing, balance, or spatial positioning. This important work impacts how well a person is able to… Read more
Career Profile
Are you interested in developing cool video game software for computers? Would you like to learn how to make software run faster and more reliably on different kinds of computers and operating systems? Do you like to apply your computer science skills to solve problems? If so, then you might be interested in the career of a computer software engineer. Read more
Career Profile
Just as a potter forms clay, or a steel worker molds molten steel, electrical and electronics engineers gather and shape electricity and use it to make products that transmit power or transmit information. Electrical and electronics engineers may specialize in one of the millions of products that make or use electricity, like cell phones, electric motors, microwaves, medical instruments, airline navigation system, or handheld games. Read more

News Feed on This Topic

 
, ,

Cite This Page

General citation information is provided here. Be sure to check the formatting, including capitalization, for the method you are using and update your citation, as needed.

MLA Style

Finio, Ben. "Program a Sound Level Meter to Help Protect Your Hearing." Science Buddies, 3 Feb. 2026, https://www.sciencebuddies.org/science-fair-projects/project-ideas/HumBio_p098/human-biology-health/sound-level-meter-microbit. Accessed 10 June 2026.

APA Style

Finio, B. (2026, February 3). Program a Sound Level Meter to Help Protect Your Hearing. Retrieved from https://www.sciencebuddies.org/science-fair-projects/project-ideas/HumBio_p098/human-biology-health/sound-level-meter-microbit


Last edit date: 2026-02-03
Top
Free science fair projects.