UnicMinds

Clap Sensor or Sound Sensor - Microbit - UnicMinds

150 dB Clap Sensor using MicroBit

Our v2 micro:bit has a microphone to listen to surrounding sounds. So, let’s write some code to make the microbit sense the sound in the surrounding and switch on or off the lights alternatively depending on the previous state.

So, we start with the first code block to recognize sound.

sound sensor microbit

And, then whatever is the previous state of the LEDs on the micorbit, we want to change it. If the LEDs are on, we want to switch them off and vice-versa. So, we need to check if the lights are on or off and accordingly do the opposite.

claps sensor microbit 150 dB

But, what is the threshold of the sound that we want this to work for? Let’s say 150 dB.

So, on the start of the program, we set the threshold to 150dB. So, if you clap slowly, it doesn’t work (shown in the video below)

sound sensor microbit

Let’s watch the program in action.

In this program, the user connected a microbit and downloaded the above program into the microcontroller. And then, the user starts to clap and sees the LEDs display in action. Again, on one more clap, the LEDs switch off to blank. This action is repeated. Observe that when the clap is lower than 150 dB, it doesn’t change the state of the LEDs.

Hope this is useful for your learning, thank you.

You may like to read: Microbit & MicroPython for Kids, Motion Blocks in Scratch, & Robotics for Kids

BOOK A FREE TRIAL