arduino-pico/libraries/ADCInput/examples/AnalogMicrophone/AnalogMicrophone.ino
Earle F. Philhower, III da26016edf
DMA-based ADC input (microphone, analog sensor) (#1101)
Mimics the I2S/PWMAudio/Stream interface for ease of use.

* Fix non-32b DMA size transfer calculation in ABM
* Rename wasHolding to isHolding in the I2S/PWM
  It is the **current** number of bits left, not the past number.
* Add commented microphone example
* Add docs
2023-01-05 16:00:34 -08:00

30 lines
705 B
C++

/*
Mono analog microphone example using electret mike on A0
Run using the Arduino Serial Plotter to see waveform.
Released to the Public Domain by Earle F. Philhower, III
Wire the mike's VCC to 3.3V on the Pico, connect the mike's
GND to a convenient Pico GND, and then connect mike OUT to A0
*/
#include <ADCInput.h>
ADCInput mike(A0);
// For stereo/dual mikes, could use this line instead
// ADCInput(A0, A1);
void setup() {
Serial.begin(115200);
mike.begin(8000);
while (1) {
Serial.printf("%d\n", mike.read());
// For stereo/dual mikes, use this line instead
// Serial.printf("%d %d\n", mike.read(), mike.read());
}
}
void loop() {
/* Nothing here */
}