In this lesson, we will introduce how to use Micro:Bit to test sound detection sensors. This test is divided into two parts, the sound sensor test in digital mode and analog mode.

Digital Mode Test

Hardware Preparation

Hardware Settings

1. Connect the Micro:Bit to the computer via a USB cable, upload the code, and unplug the Micro:Bit after the upload is complete.
2. Insert the Mciro:Bit board into the expansion board, please pay attention to the direction.
3. Connect the sound check sensor to the P1 port of the expansion board with a jumper wire.
4. Power the expansion board through the USB cable
5. Expansion board settings: please make sure the switch is set to the “ON” position, the jumper is connected to VCC and 3.3V
6. Sound sensor settings: Turn the switch on the module to “D”. Adjust the blue miniature potentiometer until the blue LED “DATA” is at the critical value of on and off, and then let the LED go out by default

Code Program

 Running Result

When the sound sensor module does not detect sound, the “DATA” LED on the module remains off. Micro Bit’s LED matrix display “”.

When the sound sensor module detects sound, the “DATA” LED on the module will be lit. Micro Bit’s LED matrix display””.

Analog Mode Test

Here the hardware preparation and hardware settings are the same as above.

Analog Read Example

Code Program

Running Result

When the sound sensor module does not detect sound, the “DATA” LED on the module remains off. The analog value read by the sensor will be displayed on the Micro Bit’s LED matrix , which is about “650”.

When the sound sensor module detects sound, the “DATA” LED on the module will be lit. The analog value read by the sensor will be displayed on the Micro Bit’s LED matrix , which is less than “630”.

NOTE:  The analog value of different sensors at the critical point can be different, please judge according to the actual situation.

Analog mode sound detection

Here the hardware preparation and hardware settings are the same as above.

Code Program

 Running Result

When the sound sensor module does not detect sound, the “DATA” LED on the module remains off.The analog value of the sensor is greater than or equal to 650, Micro Bit’s LED matrix display “”.

When the sound sensor module detects sound, the “DATA” LED on the module will be lit. The analog value of the sensor is less than 650, Micro Bit’s LED matrix display””.