04 Mission Instructions

5. Code: Find Your Threshold

Working with the loudness sensor is very similar to working with the light sensor we used in the last mission. Last time, you chose one threshold value, but this time you’ll end up choosing two! 

You will need to create two sounds — 

1. A quiet noise to represent acceptable levels of sound. It is important that your robot remains calm during everyday noises. (Have you ever heard of The Boy Who Cried Wolf? If your robot is constantly running around, alerting people to normal noise levels, eventually they will ignore the robot completely!)

2. A loud sound to represent something that could be at a high-risk volume. You could use a musical instrument, clap your hands, bang on some metal pans, or just use your voice. You may want to warn other people in your home before you start testing, though! 

The loudness sensor values can be found on the sensor control panel on the right side of your screen when you are connected to your robot and programming in Bloxter. 

Record your values on a chart like the one pictured. 

If you want to take a mathematical approach to choosing a threshold, add the high-value and low-value together, then divide that sum by 2. This will guarantee that your threshold is exactly in the middle.  You can always adjust the threshold from here. 

For your second threshold, choose something in between the middle and the loudest noise you recorded. 

Write down your two thresholds so you can easily reference them in your program later.