Datasheet

Playground Sound Meter
Use the microphone on your Circuit Playground Express to measure sound levels and display them on a VU-meter-like
display!
The program is below. There are many settings that you can change to make the readings more or less sensitive and
the display more or less jumpy. Try changing CURVE to be 4 or 1 or 10 or -2 and see what happens.
The program samples audio for a short time and the computes the energy in the sample (corresponding to volume)
using a Root-Mean-Square (https://adafru.it/Bf5) computation (RMS). You could try varying the sample size if you like.
The log_scale() function varies the number of NeoPixels lit in an exponential way, because sound levels can vary by
many factors of 10 between loud and soft. Try varying how it's computed to see what happens.
The program takes one sample when it first starts to set a "quiet" sound level. If that doesn't work for you, set
input_floor to be a fixed number. If the meter seems too sensitive, try changing input_ceiling = input_floor + 500 to
be input_ceiling = input_floor + 2000 or higher. Or go the other way.
You can also change the colors. Try different ways of computing volume_color(i) for more of a rainbow effect, or make it
a constant if you don't like changing colors.
Note: This program will only work with the improved microphone support in CircuitPython 2.2.0 or later.
# The MIT License (MIT)
#
# Copyright (c) 2017 Dan Halbert for Adafruit Industries
# Copyright (c) 2017 Kattni Rembor, Tony DiCola for Adafruit Industries
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
© Adafruit Industries https://learn.adafruit.com/adafruit-circuit-playground-express Page 174 of 211