The Adafruit PDM Mic with JST is a compact and versatile sound sensor module that captures high-quality audio signals using Pulse-Density Modulation (PDM). This microphone is ideal for a variety of applications, including sound detection, voice recognition, and audio recording in embedded systems. Its small form factor and simple interface make it a popular choice for hobbyists and professionals working on projects with microcontrollers like the Arduino UNO.
Pin Number | Name | Description |
---|---|---|
1 | SEL | Select pin for mode configuration (floating or tied to GND) |
2 | DAT | PDM data output |
3 | CLK | Clock input for PDM data |
4 | GND | Ground connection |
To use the Adafruit PDM Mic with JST in a circuit:
#include <PDM.h>
// Define the CLK and DAT pins
const int clkPin = 2; // Connect to CLK pin of the microphone
const int datPin = 3; // Connect to DAT pin of the microphone
// Buffer to store audio samples
short buffer[512];
void onPDMdata() {
// Callback function to process PDM data
int bytesAvailable = PDM.available();
PDM.read(buffer, bytesAvailable);
}
void setup() {
// Initialize serial communication
Serial.begin(9600);
// Configure the CLK and DAT pins
PDM.begin(clkPin, datPin);
// Set up the PDM microphone
PDM.setBufferSize(512);
PDM.onReceive(onPDMdata);
PDM.setGain(20);
PDM.setSampleRate(16000); // Set the sample rate to 16 kHz
}
void loop() {
// Main loop does nothing, audio processing is done in onPDMdata
}
Q: Can I use this microphone with a 5V microcontroller? A: Yes, the microphone can operate with 3.3V to 5V, but ensure that the logic levels for data and clock are compatible with your microcontroller.
Q: How do I change the sample rate?
A: The sample rate can be adjusted in the setup function using PDM.setSampleRate()
.
Q: What is the maximum distance the microphone can pick up sound? A: The effective range depends on the ambient noise and the sound volume. For clear audio, it is recommended to keep the source within a few feet of the microphone.
Remember to follow all safety precautions when working with electronic components and ensure that your work area is well-ventilated and free from static discharge.