First, sensor introduction

  1. The sensor can identify the presence or absence of a sound, but not its size or specific frequency.

  2. Sensitivity adjustable (blue digital potentiometer in the figure).

  3. Operating voltage 3.3V-5V.

  4. Output form Digital switching output (0 and 1 high and low level).

Two, sensor instructions

Wiring diagram

4. Complete code

The use of this sensor is very simple, we only use the Gpio library function provided by Core to read the level output of the sensor OUT pin to determine whether the sensor detects sound.

Configure D8 as normal output, directly attached to the Core circuit boardLED1
LIB_GpioOutputConfig("D8"."STANDARD")-- Set port D5 as normal input, connect OUT pin of sound detection sensor. You can also choose any of the d0-D7 pinsLIB_GpioInputConfig("D5"."NOPULL")-- Start the big cyclewhile(GC(1) = =true)
do
    gpio_value = LIB_GpioRead("D5")
    if gpio_value == 0Then -- Sensor OUT pin outputs low level, sensing sound LIB_GpioWrite("D8".0) - LED1 lightselse
        LIB_GpioWrite("D8".1)--LED1 indicator off end endCopy the code

Five, code running results

The LED1 light on the Core board lights up when clapping or other sounds are detected near the sensor.

Read more at shineblink.comThe website links