Approved content

The content below is provided by a partner.

sparkfun/pxt-gator-microphone 1.1.0 GitHub

gator:microphone sound Sensor

Community Discord

The gator:microphone, which includes a microphone along with an analog-to-I2C converter can be purchased here. The gator:microphone can be used to look at the envelope, or volume of sound, along with a simple gate value, which will tell whether a sound is detected above a certain threshold.

SparkFun gator:microphone

To use this package, go to https://makecode.microbit.org, click Add package and search for gator-microphone. The package is located here

Basic usage

//Reads the volume of sound
gatorMicrophone.readEnvelopeData()

Use ||Get sound intensity|| to get the value from the envelope channel.

//Reads whether or not sound is above a certain level
gatorMicrophone.readGateData()

Use ||Check for sound|| to return a boolean for whether or not the sound is above a certain level

Example: Red Detector

//Read volume value and write it to the micro:bit screen as a bar graph.
basic.forever(function () {
    led.plotBarGraph(
    gatorMicrophone.readEnvelopeData(),
    2047
    )
})

Supported targets

License

MIT