Sound Reactive Lights using MakeCode: Adafruit Circuit Playground Express

Updated 05 May 2018

The Adafruit Circuit Playground Express comes equipped with an onboard microphone that is capable of sensing both amplitude and frequency. This tutorial will walk through a quick sketch using MakeCode to turn the lights on the board into a mic activated VU-meter-like display! The microphone is located on the lower right side of the board, marked with an ear.


MakeCode

Programming sound reactive lights in MakeCode only takes a few steps. Programming a similar sketch in other languages would be quite complex even for some basic operation, so this is the sort of project where MakeCode really shines.

MakeCode Screen Adafruit Circuit Playground Express

For this example, I have used the Adafruit MakeCode app so we can see live data from the microphone on the Circuit Playground Express. All it takes to get the lights to act as a sound reactive VU meter is drag the graph command into the forever loop, and then change the first variable to a sound level input. The second number in the graph is the high limit of detection. The microphone returns an analog value between 0 and 255. You should set the second number to no higher than 255 because the mic cannot detect anything louder. In the example, the upper limit is 100, because I found that most of the sounds I made didn’t exceed 100 so setting it lower makes for more motion on the NeoPixels.
I have also added a slide switch actions. When the slide switch is left the brightness is set to low, and when the slide switch is right the brightness is fully bright.

Show Console Device

MakeCode Console Screen Adafruit

The Show Console Device option within the Adafruit MakeCode App (available free on the Windows App Store) allows us to view real-time data coming from a connected Circuit Playground Express. This screenshot shows the levels detected on the microphone while I was speaking. This allows you to set the upper limit of the graph function to a reasonable level to get the most dynamic looking lights. We don’t want to have to shout to get all the lights on!
MakeCode makes programs like this easy, but don’t be fooled by its simple appearance, its still a very capable editor! For more tutorials on the Adafruit Circuit Playground Express, check out our Circuit Playground Tutorial page. If you are interested in learning how to program sound reactive lights in CircuitPython, we have a tutorial for that too!

Have a question? Ask the Author of this guide today!

Please enter minimum 20 characters

Your comment will be posted (automatically) on our Support Forum which is publicly accessible. Don't enter private information, such as your phone number.

Expect a quick reply during business hours, many of us check-in over the weekend as well.

Comments


Loading...
Feedback

Please continue if you would like to leave feedback for any of these topics:

  • Website features/issues
  • Content errors/improvements
  • Missing products/categories
  • Product assignments to categories
  • Search results relevance

For all other inquiries (orders status, stock levels, etc), please contact our support team for quick assistance.

Note: click continue and a draft email will be opened to edit. If you don't have an email client on your device, then send a message via the chat icon on the bottom left of our website.

Makers love reviews as much as you do, please follow this link to review the products you have purchased.