STEP1: Connect the sound sensor module to the pin P0 of the extension board; LED module to P1.
1. Let’s begin to design our project according to the tips: drag “read analog pin P0” and “display” blocks from the “Micro: bit” module; drag out “if… then…else” block from the “Control” module; drag “<” in the “Operation” module to script area.
2. Read the analog value(0~1023) of “read analog pin P0” that connected with sound sensor to detect the sound of intensity.
3. Edit the programs to realize “sound intensity detecting”. “<” can be used to judge if the analog value of sound intensity meets the set standard.
AS shown in figure 3.1.4, if the condition “’read analog pin P0’<’80’” is true, also means the sound intensity grade is 1, the on-board LED displays figure “1”.
If the condition is false, the sound intensity grades 2 and the LED displays figure”2”. Add a “wait 1 sec” block under the “...then” to prevent the LED figure from flashing.
Control the LED to turn on/off according to the value of the pin connected to the sound sensor.
1. Drag “set digital pin P0 output” block from “micro: bit” module to script area, and change P0 to P1.
2. Programming to make a “electronic candle”
When the analog value of sound sensor is less than the preset value 80, the LED keeps on, otherwise, blow it like a candle, when the sound intensity is over 80, the LED keeps off for 2 seconds.