This code imports the audiobusio, time, board, array and math libraries. There are also two helper functions. The first one uses math to return a mean, or average. It is used in the second helper. The second felper function uses math to return a normalised rms average. These functions are then used to take multiple sound samples really quickly and average them to get a more accurate reading.

Next the microphone object and the samples variable are set. Then initialization of the mic object so it's ready for use.

The mic object starts taking sound samples. The normalised rms is used to find the average of a given set of samples, and that is the magnitude. Last, print the magnitude to the serial console.

Press the Serial button to see the values being printed out. Press the Plotter icon to have Mu plot those values also. Note that the Mu plotter looks for tuple values to print. Tuples in Python come in parentheses () with comma separators. If you have two values, a tuple would look like (1.0, 3.14) Since we have only one value, we need to have it print out like (1.0,) note the parentheses around the number, and the comma after the number. Thus the extra parentheses and comma in print(((magnitude),)).

Once you have everything setup and running, try speaking towards the Circuit Playground Express, and watch the plotter immediately react! Move further away from the board to cause smaller changes in the plotter line. Move closer to the board to see bigger spikes!

It's a really easy way to test your microphone and see how it reads sound changes on the Circuit Playground Express!

Advanced - an Analog Sound Meter

Some Makers look to build a classic sound meter - the rainbow meter that measures sound with sample normalization and logarithmic scaling.

OUT OF STOCK NOTIFICATION

YOUR NAME

YOUR EMAIL

You have been successfully subscribed to the Notification List for this product and will therefore receive an e-mail from us when it is back in stock!

For security reasons, an e-mail has been sent to you acknowledging your subscription. Please remember that this subscription will not result in you receiving any e-mail from us about anything other than the restocking of this item.

If, for any reason, you would like to unsubscribe from the Notification List for this product you will find details of how to do so in the e-mail that has just been sent to you!