0

empowering creative people

Videos / Sound Reactive Lights Project with Circuit Playground & MakeCode

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

Search Videos

Related Content

Transcript

+

Hi there, Steven here from Core Electronics. I'm here today to talk to you about making Some Reactive Lights using MakeCode and the Adafruit Circuit Playground Express.

The Circuit Playground Express is a great platform for educators, specifically because it's made to interface with MakeCode and it's such a simple interface it's drag-and-drop locks, rather than typing code, you don't need to have any prior knowledge of code to be able to use it and it's really rewarding. It allows you to make some complex programs without any knowledge at all and you get good immediate results from it.

So, if we look at our board, we're going to use the microphone today as you can see I already have our sketch uploaded on the board. The microphone is right here on the board and it's marked with an ear. It's a cool feature on the board because it's not just amplitude sensing like most microphones, it's also capable of sensing frequencies. So, the result is straightforward, as more sound is detected more lights are lit up around the wheel and we have kind of a rainbow pattern that goes along with it. So, let's look at our code.

If we open up MakeCode, I'm using the Windows desktop version of the interface for MakeCode today rather, than the in-browser version and I'll show you why in a minute, it's because we'll be able to use the show console, which gives live readings from the Circuit Playground Express and the programs free, you can get it on the Windows App Store or offline. So just to show you how simple it is within MakeCode to make a program like this, is that we have our forever loop, if we take the graph command and then do input of sound level, then and we'll say up to 100, the microphone will return a value of 0 to 255. So, if you want to make your microphones seem a little more sensitive, then you can do a lower number like 100, like I have so you don't need to yell at it to get all the lights to light up.

This program right here is already enough to give you the results that we see right now on the board it's that simple like this would take quite a bit of complicated math in a normal programming language and it can be quite a complex program, but it's all just contained in this one block in MakeCode. So that's one of the ways that it really gives you like satisfactory results without too much work going into it.

Just to add a little bit another element to our program, we're going to use the slide switch as well, which we haven't used yet. So, with inputs we have a on slide switch moved command, so we'll have an on-slide switch moved left and we'll do another one for right and then we'll just have that control the brightness. So, if we go into lights and grab a set brightness and put that within each, then we can set one way to be fully bright and the other way to be a little dimmer and because we're using the desktop version and our boards already connected all we need to do to load our code onto the board is hit download. It detects that we have a Circuit Playground Express already connect it automatically, it uploads our code and now we have our code on the board in it everything restarts and keeps going right away.

So, as you can see now if we move the slide switch to the right, we have much brighter lights if we move them back to the left then they're a little dimmer and a little easier on the eyes. So earlier I mentioned the serial monitor show console device option of the MakeCode editors, so I'll just show you that now.

If we look under the virtual interface we have a show console device button, and this is a serial monitor, that's in real time showing us what the microphone is sensing and then plotting it into a graph automatically. So, as you can see when I'm talking it's spiking between four and seventy-five and when I'm silent it's returning low values and you can hover your mouse over the graph at any point and I'll show you what that value is. You can pause it and restart it and one of the coolest features I think is, that up here in the top right corner you can export the data and that will automatically take all the data that it's recorded and export it into a Microsoft Excel spreadsheet, where you can access it and manipulate it in any way you might want and I think that's a really good tool for educators, potentially that want to bring in a little bit more of a scientific experience with the Adafruit Circuit Playground Express.

So that wraps up my tutorial on how to make Sound Reactive Lights using MakeCode for the Adafruit Circuit Playground Express. We've got a lot more content over in our tutorials section for this board using both Circuit Python and MakeCode.

Check out our forums if you have any questions or comments. Thanks for listening.

comments