English
English
简体中文
日本語

Arduino Quick Start

2. Devices & Examples

5. Extensions

6. Applications

Microphone Module

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.

Hardware Connection

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.

Example Program

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.

cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
#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.

Page Tools
PDF
On This Page