Introduction
Learn how to use the sound sensor onboard the Circuit Playground Express! This tutorial uses MakeCode, which is an easy-to-use code writing program!
-
-
To start using a Circuit Playground, you'll need a laptop, a circuit playground, and a USB cable
-
If you've never used makecode before, check out this tutorial to learn about it
-
-
-
Ignore the forever loop that is already there, it'll be used later.
-
Place an on start loop in the workspace.
-
Inside the on start loop, place a set all pixels to... block. Change the color to black
-
This doesn't turn the pixels fully off, but rather makes it so they don't emit any light!
-
Place a set brightness block inside the loop as well. Change the brightness to whatever you'd like
-
Finally, add a set loud sound threshold block. This will determine how loud a sound has to be to turn the lights on. Change the threshold as you see fit.
-
-
-
Drag out an on loud sound block from the input menu
-
Inside the block, add a set all pixels to followed by a pause block. Change the duration of the pause to at least 500 ms.
-
After the pause, insert another set all pixels to block and change the color to black
-
-
-
Plug the circuit playground into your laptop using the usb cable
-
Download your code and follow the instructions in MakeCode to write the code to the board
-
-
-
For the challenge, try writing the code so that the leds are on when the volume is above a certain level
-
You'll need a forever loop, an if...else logic loop, a comparison statement, and the sound level from the input menu
-
You can use the interactive volume slider to test your code before writing it to board. Click and drag to change the volume of the sound
-
Circuit Playground Sound Sensor: Quiz