English
English
简体中文
日本語
pdf-icon

Arduino Quick Start

2. Devices & Examples

5. Extensions

6. Applications

CoreS3 Speaker

CoreS3 Speaker related APIs and example programs.

Example Program

Compilation Requirements

  • M5Stack Board Manager version >= 3.2.2
  • Board selection = M5CoreS3
  • M5Unified library version >= 0.2.11
cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#include "M5Unified.h"

void setup() {
    auto cfg = M5.config();
    M5.begin(cfg);
    M5.Display.setRotation(1);
    M5.Display.setTextColor(GREEN);
    M5.Display.setTextDatum(middle_center);
    M5.Display.setTextFont(&fonts::Orbitron_Light_24);
    M5.Display.setTextSize(1);
    M5.Display.drawString("Speaker Test", M5.Display.width() / 2,
                                M5.Display.height() / 2);
}

void loop() {
    M5.Speaker.tone(10000, 100);
    delay(1000);
    M5.Speaker.tone(4000, 20);
    delay(1000);
}

After successful upload, you will hear the CoreS3 speaker emit sounds of different frequencies, 10kHz and 4kHz respectively, each lasting 1 second.

API

The CoreS3 Speaker driver section uses the Speaker_Class from the M5Unified library. For more related APIs, please refer to the documentation below:

On This Page