Welcome to the DFRobot blog
:
www.dfrobot.com/blog-tag-microbit.html
40
/
86
STEP 3: Now, we will need to let the program determine the level of the voice. The operator "<"
under the “Logic” does the job. As shown in the picture below, When the analog value of sound
sensor is less than 50, the on-board LED displays a number "1", indicating that the volume is low;
when it is greater than 50, the on-board LED displays a number "2", indicating that the volume is
high.
Make some noise around the sensor, or simply blow some air to test if the micro: bit is able to show
different number with respect to the volume.
Also, if the sensor is being too responsive, you may need to change the “50” after the “<” operator.
It also works the same way around if the sensor is not responsive.
Task 2: electronic candle
Goal: The micro: bit can measure the volume using the sound sensor, based on that, we want to
use it to control the candle. Here is what we are going to program: once we blow air towards the
sensor, the candle goes off for a second.
STEP 1: We will use the “if else” function again in our program. However, instead of controlling an
LED panel, we just need to control the LED connects to P2. The logic is very straight forward, once
the volume exceeds the preset value, the light turns on, vice versa. Since we want the candle to
keep on burning, the program should be put inside the “forever” loop.