
Arduino Quick Start
The Microphone module integrates a MAX4466 microphone preamplifier and can capture analog and digital signals from the microphone input. An adjustable resistor lets the user set the detection threshold.
The Microphone module supports both digital and analog readings. Note that not all GPIO pins on the Basic support ADC conversion. When using analog readings, connect the signal to an ADC-capable pin such as 34, 35, or 36; any general-purpose GPIO can be used for digital readings.
This example reads the microphone module's analog and digital outputs and displays the raw ADC value and digital level on the screen and serial monitor.
#include <M5Unified.h>
#include <M5GFX.h>
const int Analog = 36;
const int Digital = 2;
uint16_t a_data;
uint16_t d_data;
void setup() {
// put your setup code here, to run once:
M5.begin();
pinMode(Digital, INPUT_PULLUP);
dacWrite(25, 0);
M5.Lcd.setCursor(100, 0, 4);
M5.Lcd.print("MICROPHONE");
}
void loop() {
// put your main code here, to run repeatedly:
a_data = analogRead(Analog);
d_data = digitalRead(Digital);
Serial.printf("Analog:%0d\n", a_data);
Serial.printf("Digital:%0d\n", d_data);
M5.Lcd.setCursor(30, 100, 4);
M5.Lcd.printf("Analog:%4d ", a_data);
M5.Lcd.setCursor(30, 140, 4);
M5.Lcd.printf("Digital:%4d ", d_data);
delay(200);
}After uploading the program, you should see the following result.
